Closed Bug 942774 Opened 11 years ago Closed 10 years ago

Files loaded into scratchpad should be recognized as “saved”

Categories

(DevTools Graveyard :: Scratchpad, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 29

People

(Reporter: PatrickWesterhoff, Assigned: lpy)

Details

(Whiteboard: [good-first-bug][lang=js][mentor=Benvie][good first verify])

Attachments

(1 file, 1 obsolete file)

Currently, when loading a file into Scratchpad, the file is immediately marked as “not saved” (visible by the star prepended to the file name in the title). Thus, when closing Scratchpad without actually changing the file, I still get a prompt to save it.

This is obviously not necessary for files that were just loaded but never changed.

The behavior is triggered by `self.setText(content);` in the `SP_importFromFile` function [1]. Setting the text will raise the `textChanged` event which in turn will put the Scratchpad editor in an unsaved state.

It seems that the `textChanged` event is only being listened to when the file was saved until the first change. I would suggest solving this similarly to how it’s done in the initialization by calling `onTextSaved` after the text has been loaded from the file [3]. In addition this would require removing the listener first before starting to load the file.


[1] https://hg.mozilla.org/mozilla-central/file/94a04fd2568d/browser/devtools/scratchpad/scratchpad.js#l578
[2] https://hg.mozilla.org/mozilla-central/file/94a04fd2568d/browser/devtools/scratchpad/scratchpad.js#l882
[3] https://hg.mozilla.org/mozilla-central/file/94a04fd2568d/browser/devtools/scratchpad/scratchpad.js#l792
(In reply to Patrick Westerhoff from comment #0)
> This is obviously not necessary for files that were just loaded but never
> changed.
Agreed.
Confirmed on 28.0a1 (2013-12-09), Win 7 x64.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [good-first-bug][lang=js][mentor=Benvie]
I would like to work on the bug. Can I be assigned to it?
sure, Bhagya. Attach a patch and we'll set the assignee to you. Thanks!
Can you please assign this bug to me? I am interested in working on this bug.
Assignee: nobody → pylaurent1314
Attached patch bug942774.patch (obsolete) — Splinter Review
The code link in description are out of date.
Attachment #8362223 - Flags: review?(bbenvie)
Is that really all that’s necessary now to fix this? Wow, a lot seems to have happened in that file :o
The |set dirty| will call |setClean| in the editor and update the title. I think that can solve this problem. Any suggestion appreciated.

[1]http://dxr.mozilla.org/mozilla-central/source/browser/devtools/scratchpad/scratchpad.js#164
This looks like the correct fix, but I'd also like to see a test added to confirms this behavior so it won't break in the future again. You should be able to add a check somewhere around [1] to confirm that gScratchpad.dirty is false.

[1] http://mxr.mozilla.org/mozilla-central/source/browser/devtools/scratchpad/test/browser_scratchpad_files.js#45
Attachment #8362223 - Flags: review?(bbenvie)
Test added. Thank you.
Attachment #8362223 - Attachment is obsolete: true
Attachment #8362344 - Flags: review?(bbenvie)
Comment on attachment 8362344 [details] [diff] [review]
bug942774-V2.patch

Review of attachment 8362344 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks! LGTM pending a green try.

https://tbpl.mozilla.org/?tree=Try&rev=46ff5902f513
Attachment #8362344 - Flags: review?(bbenvie) → review+
https://hg.mozilla.org/integration/fx-team/rev/cbb2876bdaf3
Whiteboard: [good-first-bug][lang=js][mentor=Benvie] → [good-first-bug][lang=js][mentor=Benvie][fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/cbb2876bdaf3
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [good-first-bug][lang=js][mentor=Benvie][fixed-in-fx-team] → [good-first-bug][lang=js][mentor=Benvie]
Target Milestone: --- → Firefox 29
Whiteboard: [good-first-bug][lang=js][mentor=Benvie] → [good-first-bug][lang=js][mentor=Benvie][good first verify]
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: