Closed Bug 700893 Opened 10 years ago Closed 10 years ago
API for tracking unsaved/saved state in source editor
As brought up in bug 669612, there should be a way to tell the source editor "this text is 'saved'", and a way to query whether the text is still in that 'saved' state, across changes and undos.
Perhaps it would make sense to implement the Save to file feature within SourceEditor to avoid duplication as well?
(In reply to Cedric Vivier [cedricv] from comment #1) > Perhaps it would make sense to implement the Save to file feature within > SourceEditor to avoid duplication as well? Interesting idea. Currently I want to keep the Source Editor a "text widget" with the common features needed to build the UI of devtools, for source code editing. Syntax highlighting, rulers, autocomplete and so on. Saving files is what the user of the Source Editor might want to do, but not always. We'll see, in the future. The Orion editor upstream has the concept of tracking the "dirty"/saved/unsaved state. Save is also a command that is implemented externally - it's up to the integrator what save means. That's what I imagine for our Source Editor as well. We just didn't (yet) take in this part of their code. We'll see in the future. Anyhow, this bug is about the saved state. :)
Version: unspecified → Trunk
One potential way to implement this would be to verify the content's of the editor's undo stack. If the stack is empty, the file is back to "saved" or "unchanged". If there are undos on the stack, then the file is considered modified. This seems to match up with the way other editors (e.g., TextMate) check their modified state.
Component: Developer Tools → Developer Tools: Scratchpad
QA Contact: developer.tools → developer.tools.scratchpad
This now blocks bug 684445 because we need a proper way to update the undo/redo xul:commands. I already have patches in the works for both bugs.
Assignee: nobody → mihai.sucan
Status: NEW → ASSIGNED
Proposed patch. Note that this also fixes bug 723057.
The new Source Editor API event, DIRTY_CHANGED, and the new editor.dirty property need to be documented. Example use is in scratchpad.js. Thank you!
Comment on attachment 595790 [details] [diff] [review] [in-fx-team] rebased patch solid. I wish I had some comments for you, but it all looks ok to my pre-caffeinated self. You could ask harth for feedback around the Scratchpad title-marking and saving stuff and I will do so.
Thanks Rob for the r+! Yep, it makes sense to ask Heather for a feedback round. Looking forward to her feedback!
Comment on attachment 595790 [details] [diff] [review] [in-fx-team] rebased patch looks good to me too.
Attachment #595790 - Flags: feedback?(fayearthur) → feedback+
Comment on attachment 595790 [details] [diff] [review] [in-fx-team] rebased patch Landed: https://hg.mozilla.org/integration/fx-team/rev/5b33f5c7e630
Attachment #595790 - Attachment description: rebased patch → [in-fx-team] rebased patch
Thanks Heather for the f+!
Whiteboard: [sourceeditor] → [sourceeditor][fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [sourceeditor][fixed-in-fx-team] → [sourceeditor]
Target Milestone: --- → Firefox 13
You need to log in before you can comment on or make changes to this bug.