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. :)
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.
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.
Created attachment 593586 [details] [diff] [review] proposed patch Proposed patch. Note that this also fixes bug 723057.
Created attachment 595790 [details] [diff] [review] [in-fx-team] rebased patch
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.
Comment on attachment 595790 [details] [diff] [review] [in-fx-team] rebased patch Landed: https://hg.mozilla.org/integration/fx-team/rev/5b33f5c7e630
Thanks Heather for the f+!