reset undo stack after setValue() calls

This commit is contained in:
Fabian Jakobs 2011-02-19 11:36:58 +01:00
commit b01e4c8640
2 changed files with 11 additions and 5 deletions

View file

@ -94,8 +94,9 @@ var EditSession = function(text, mode) {
}; };
this.setValue = function(text) { this.setValue = function(text) {
this.doc.setValue(text); this.doc.setValue(text);
this.$deltas = []; this.$deltas = [];
this.$undoManager.reset();
}; };
this.getValue = this.getValue =
@ -130,7 +131,8 @@ var EditSession = function(text, mode) {
this.$defaultUndoManager = { this.$defaultUndoManager = {
undo: function() {}, undo: function() {},
redo: function() {} redo: function() {},
reset: function() {}
}; };
this.getUndoManager = function() { this.getUndoManager = function() {

View file

@ -38,8 +38,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var UndoManager = function() { var UndoManager = function() {
this.$undoStack = []; this.reset();
this.$redoStack = [];
}; };
(function() { (function() {
@ -65,6 +64,11 @@ var UndoManager = function() {
this.$undoStack.push(deltas); this.$undoStack.push(deltas);
} }
}; };
this.reset = function() {
this.$undoStack = [];
this.$redoStack = [];
};
}).call(UndoManager.prototype); }).call(UndoManager.prototype);