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

Simplify dirty bit management #161

Merged
merged 3 commits into from
Jan 28, 2012
Merged

Simplify dirty bit management #161

merged 3 commits into from
Jan 28, 2012

Conversation

njx
Copy link

@njx njx commented Jan 28, 2012

Issue #152 exposed a problem with our dirty bit management, which was relying on CodeMirror's undo history. Because CodeMirror limits the size of its undo history, our logic for figuring out when to clear the dirty bit due to an undo was incorrect.

The real fix for this would be to add the dirty bit tracking to CodeMirror. For now, we're simplifying the dirty bit management so that we simply mark documents as dirty as soon as you make a change, and only mark them clean again on save. If you undo back to your previous save state, the document is still marked dirty. This avoids the data loss issue from 152, but is not as good from the user's point of view. We'll add a user story to the product backlog to get back to the previous functionality.

@ghost ghost assigned peterflynn Jan 28, 2012
* @param {!string} text The text to replace the contents of the document with.
*/
Document.prototype.setText = function(text) {
console.assert(this._editor != null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always go back and forth on whether it's worth it to have an assert() if the next line of code is guaranteed to crash anyway (NPE in this case)... but feel free to keep it in if you like it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just following the existing code from getText()...I'm fine with removing it.

@peterflynn
Copy link
Member

Done with comments. Looks great other than those few nits.

@peterflynn
Copy link
Member

Looks good. Merging...

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

Successfully merging this pull request may close these issues.

2 participants