make sure edit ids are always unique

pull/85/head
nightwing 2014-12-27 12:59:59 +04:00
rodzic f04f22076c
commit c9f492a916
1 zmienionych plików z 14 dodań i 7 usunięć

21
node_modules/ace/lib/ace/undomanager.js wygenerowano vendored
Wyświetl plik

@ -42,6 +42,8 @@ define(function(require, exports, module) {
* @constructor
**/
var UndoManager = function() {
this.$maxRev = 0;
this.mark = 0;
this.reset();
};
@ -60,8 +62,7 @@ var UndoManager = function() {
if (this.$session.mergeUndoDeltas === false || !this.lastDeltas) {
this.lastDeltas = [];
this.$undoStack.push(this.lastDeltas);
this.$rev++;
delta.id = this.$rev;
delta.id = this.$rev = ++this.$maxRev;
}
this.lastDeltas.push(delta);
};
@ -167,6 +168,9 @@ var UndoManager = function() {
var diff = this.getDeltas(this.$redoStackBaseRev, this.$rev + 1);
rebaseRedoStack(this.$redoStack, diff);
this.$redoStackBaseRev = this.$rev;
this.$redoStack.forEach(function(x) {
x[0].id = ++this.$maxRev;
}, this);
}
var deltaSet = this.$redoStack.pop();
var redoSelectionRange = null;
@ -217,8 +221,11 @@ var UndoManager = function() {
/**
* Marks the current status clean
**/
this.markClean = function() {
this.dirtyCounter = 0;
this.bookmark =
this.markClean = function(rev) {
if (rev == undefined)
rev = this.$rev;
this.mark = rev;
};
/**
@ -226,7 +233,7 @@ var UndoManager = function() {
* @returns {Boolean}
**/
this.isClean = function() {
return this.dirtyCounter === 0;
return this.$rev === this.mark;
};
@ -245,7 +252,7 @@ function findDelta(stack, pos) {
break;
}
}
};
}
var Range = require("./range").Range;
var cmp = Range.comparePoints;
@ -537,6 +544,6 @@ function rebaseRedoStack(redoStack, deltaSets) {
}
}
UndoManager.swapGroups = swapGroups;
exports.UndoManager = UndoManager;
});