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

View file

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