marijnh/CodeMirror — Issue #58: setValue() clears undo history
Author: claviska
Created: 2011-10-17 20:36:14+00:00
State: open

When calling setValue() the undo history gets cleared. A real-world example of when this would be undesirable is as follows:

1. User loads CodeMirror-enabled page to edit something
2. User makes a few changes to the source
3. User clicks on a "Cleanup" button that sends an AJAX request to Tidy, BeautifyJS, or something similar.
4. Source gets updated programmatically (using setValue) and undo history is cleared
5. User wishes to undo his changes

This is one of the ways I'm using CodeMirror 2, which is why I've come across this issue. I think the following may be a feasible solution:

1. Don't clear the undo history on setValue()
2. Add a reset method to clear the undo/redo levels programmatically

What are your thoughts on this, Marijn?