Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Quick Editor dirty mark doesn't work #7571

Open
marcelgerber opened this issue Apr 19, 2014 · 5 comments
Open

Quick Editor dirty mark doesn't work #7571

marcelgerber opened this issue Apr 19, 2014 · 5 comments

Comments

@marcelgerber
Copy link
Contributor

  1. Open any JavaScript Inline Editor (Ctrl+E)
  2. Do some change
  3. Revert using Ctrl+Z

Result: There's still a "dirty mark" (dot before filename)
Expected: No dirty mark

@peterflynn
Copy link
Member

This is a known issue that we can't fix without changing how the Document model handles multiple editors - see https://trello.com/c/cRAl0YHB/774-2-doc-linking-for-inline-editors. Undo in an inline editor isn't "real" undo yet -- it just makes another edit that happens to cancel out the previous one, so the master undo history has two changes instead of zero, and thus is still "dirty."

@wnr
Copy link

wnr commented Apr 21, 2014

Also, if the editor is changed back to it's original state it will still show the dirty mark.

For example: If a file originally has the content "abc", removing the a so the new content is "bc" will mark the file as dirty. Putting back the a so the content again is "abc" does not remove the dirty mark.

When the Editor._handleEditorChanges are fired (by an inline editor undo), the secondary editor (the inline editor making the actual change) will have it's codemirror.isClean() = true. However, the _applyChanges(changeList); call (that syncs the changes of the secondary and master editor by doing the CM operations on master) indeed does the changes, but CM does not recognize that the document has been restored to it's original state. If CM implements this feature, then this problem will be automatically solved by brackets current behavior.

In summary: If CM implements the feature to detect (and mark clean) when a document has been restored to it's original state (by changes or undos), this issue will be resolved automatically.

@njx
Copy link
Contributor

njx commented Apr 21, 2014

That's not really a CM bug. The issue is that we're not using CM linked documents to synchronize the two documents - we're doing our own hack (which we implemented before CM implemented linked docs) that doesn't really do the right thing with undo history and the clean state. So we really need to use the doc linking feature in order to fix this properly.

@peterflynn
Copy link
Member

And in general editors do not remove the dirty marker if you do a series of edits that just happen to make the text identical to the earlier state. You only want to hide the dirty marker if the undo/redo stack matches the state when last saved. I'd be surprised if you could find editors where the "abc"/"bc" example above actually behaves as suggested...

@wnr
Copy link

wnr commented Apr 21, 2014

Ah okay, my bad. I thought Sublime worked that way but it does indeed not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants