API for tracking unsaved/saved state in source editor

RESOLVED FIXED in Firefox 13

Status

()

Firefox
Developer Tools: Scratchpad
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: harth, Assigned: msucan)

Tracking

({dev-doc-complete})

Trunk
Firefox 13
dev-doc-complete
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [sourceeditor])

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
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?
(Assignee)

Comment 2

6 years ago
(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
(Assignee)

Comment 4

5 years ago
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
(Assignee)

Updated

5 years ago
Blocks: 723057
(Assignee)

Comment 5

5 years ago
Created attachment 593586 [details] [diff] [review]
proposed patch

Proposed patch. Note that this also fixes bug 723057.
Attachment #593586 - Flags: review?(rcampbell)
(Assignee)

Updated

5 years ago
Depends on: 717613
(Assignee)

Comment 6

5 years ago
Created attachment 595790 [details] [diff] [review]
[in-fx-team] rebased patch
Attachment #593586 - Attachment is obsolete: true
Attachment #593586 - Flags: review?(rcampbell)
Attachment #595790 - Flags: review?(rcampbell)
(Assignee)

Comment 7

5 years ago
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)
(Assignee)

Comment 9

5 years ago
Thanks Rob for the r+!

Yep, it makes sense to ask Heather for a feedback round. Looking forward to her feedback!
(Reporter)

Comment 10

5 years ago
Comment on attachment 595790 [details] [diff] [review]
[in-fx-team] rebased patch

looks good to me too.
Attachment #595790 - Flags: feedback?(fayearthur) → feedback+
(Assignee)

Comment 11

5 years ago
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
(Assignee)

Comment 12

5 years ago
Thanks Heather for the f+!
Whiteboard: [sourceeditor] → [sourceeditor][fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/5b33f5c7e630
Status: ASSIGNED → RESOLVED
Last Resolved: 5 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.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.