kopia lustrzana https://github.com/c9/core
fix failing tests
rodzic
ce06798521
commit
e7c56ee45c
|
@ -219,7 +219,7 @@ var UndoManager = function() {
|
|||
this.$undoStack = [];
|
||||
this.$redoStack = [];
|
||||
this.$rev = 0;
|
||||
this.mark = -1;
|
||||
this.mark = 0;
|
||||
this.$redoStackBaseRev = this.$rev;
|
||||
this.selections = [];
|
||||
};
|
||||
|
@ -552,7 +552,7 @@ function moveDeltasByOne(redoStack, d) {
|
|||
d = cloneDelta(d);
|
||||
for (var j = redoStack.length; j--;) {
|
||||
var deltaSet = redoStack[j];
|
||||
for (var i = deltaSet.length; i--;) {
|
||||
for (var i = deltaSet.length; i--> 0;) {
|
||||
var x = deltaSet[i];
|
||||
var xformed = xform(x, d);
|
||||
d = xformed[0];
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = {
|
|||
session.setValue("012345-012345-012345");
|
||||
session.insert({row: 0, column: 0}, "xx");
|
||||
session.markUndoGroup();
|
||||
session.remove({start: {row: 0, column: 10}, end: {row: 0, column: 15}});
|
||||
session.remove(new Range(0, 10, 0, 15));
|
||||
session.markUndoGroup();
|
||||
session.insert({row: 0, column: 5}, "yy");
|
||||
session.markUndoGroup();
|
||||
|
@ -82,6 +82,25 @@ module.exports = {
|
|||
editor.redo();
|
||||
var val2 = editor.getValue();
|
||||
assert.equal(val1, val2);
|
||||
},
|
||||
"test: conflicting deletes": function() {
|
||||
var session = new EditSession("");
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
var undoManager = new UndoManager();
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
session.setValue("012345\nabcdefg\nxyz");
|
||||
session.remove(new Range(0, 2, 0, 4));
|
||||
assert.equal(session.getLine(0), "0145");
|
||||
session.markUndoGroup();
|
||||
editor.undo();
|
||||
session.remove(new Range(0, 1, 0, 5));
|
||||
assert.equal(session.getLine(0), "05");
|
||||
session.markUndoGroup();
|
||||
editor.redo();
|
||||
assert.equal(session.getLine(0), "05");
|
||||
editor.undo();
|
||||
assert.equal(session.getLine(0), "012345");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -358,7 +358,6 @@ define(function(require, exports, module) {
|
|||
return this.$aceUndo.markIgnored(from, to);
|
||||
},
|
||||
getState: function() {
|
||||
console.log("getState()");
|
||||
var aceUndo = this.$aceUndo;
|
||||
var mark = -1;
|
||||
var aceMark = aceUndo.mark;
|
||||
|
@ -380,7 +379,6 @@ define(function(require, exports, module) {
|
|||
};
|
||||
},
|
||||
setState: function(e, silent) {
|
||||
console.log("setState()");
|
||||
var aceUndo = this.$aceUndo;
|
||||
var stack = e.stack || [];
|
||||
var marked = stack[e.mark] && stack[e.mark][0];
|
||||
|
@ -397,9 +395,15 @@ define(function(require, exports, module) {
|
|||
var lastDeltaGroup = stack[stack.length - 1];
|
||||
var lastRev = lastDeltaGroup && lastDeltaGroup[0].id || 0;
|
||||
aceUndo.$rev = lastRev;
|
||||
aceUndo.$redoStackBaseRev == aceUndo.$rev;
|
||||
aceUndo.$redoStackBaseRev = aceUndo.$rev;
|
||||
aceUndo.$maxRev = Math.max(aceUndo.$maxRev, lastRev);
|
||||
this.$aceUndo.bookmark(marked && marked.id != null ? marked.id : -1);
|
||||
var markedRev = marked && marked.id;
|
||||
if (markedRev != null)
|
||||
this.$aceUndo.bookmark(markedRev);
|
||||
else if (e.mark == e.position)
|
||||
this.$aceUndo.bookmark();
|
||||
else
|
||||
this.$aceUndo.bookmark(-1);
|
||||
silent || this._emit("change");
|
||||
},
|
||||
isAtBookmark: function() {
|
||||
|
@ -419,6 +423,7 @@ define(function(require, exports, module) {
|
|||
}
|
||||
var deltaSet = stack[index];
|
||||
var rev = deltaSet && deltaSet[0] && deltaSet[0].id;
|
||||
if (rev == null) rev = -1;
|
||||
this.$aceUndo.bookmark(rev);
|
||||
} else if (index == -1) {
|
||||
this.$aceUndo.bookmark(0);
|
||||
|
|
Ładowanie…
Reference in New Issue