Closed Bug 700893 Opened 9 years ago Closed 9 years ago

API for tracking unsaved/saved state in source editor

Categories

(DevTools Graveyard :: Scratchpad, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 13

People

(Reporter: harth, Assigned: msucan)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [sourceeditor])

Attachments

(1 file, 1 obsolete file)

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. :)
Whiteboard: [sourceeditor]
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
Blocks: 684445
Status: NEW → ASSIGNED
Blocks: 723057
Attached patch proposed patch (obsolete) — Splinter Review
Proposed patch. Note that this also fixes bug 723057.
Attachment #593586 - Flags: review?(rcampbell)
Depends on: 717613
Attachment #593586 - Attachment is obsolete: true
Attachment #593586 - Flags: review?(rcampbell)
Attachment #595790 - Flags: review?(rcampbell)
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!
Keywords: dev-doc-needed
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.
Attachment #595790 - Flags: review?(rcampbell)
Attachment #595790 - Flags: review+
Attachment #595790 - Flags: feedback?(fayearthur)
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]
https://hg.mozilla.org/mozilla-central/rev/5b33f5c7e630
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: [sourceeditor][fixed-in-fx-team] → [sourceeditor]
Target Milestone: --- → Firefox 13
This is already documented on:

https://developer.mozilla.org/en/JavaScript_code_modules/source-editor.jsm

Added to Firefox 13 for developers.
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.