Fix handling of undo/redo stack in splits do the right thing.
This commit is contained in:
parent
ffeda1ae05
commit
f332e2b900
3 changed files with 26 additions and 18 deletions
|
|
@ -694,7 +694,7 @@ var EditSession = function(text, mode) {
|
||||||
return this.doc.remove(range);
|
return this.doc.remove(range);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.undoChanges = function(deltas) {
|
this.undoChanges = function(deltas, dontSelect) {
|
||||||
if (!deltas.length)
|
if (!deltas.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -713,10 +713,13 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$fromUndo = false;
|
this.$fromUndo = false;
|
||||||
lastUndoRange && this.selection.setSelectionRange(lastUndoRange);
|
lastUndoRange &&
|
||||||
|
!dontSelect &&
|
||||||
|
this.selection.setSelectionRange(lastUndoRange);
|
||||||
|
return lastUndoRange;
|
||||||
},
|
},
|
||||||
|
|
||||||
this.redoChanges = function(deltas) {
|
this.redoChanges = function(deltas, dontSelect) {
|
||||||
if (!deltas.length)
|
if (!deltas.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -731,7 +734,10 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$fromUndo = false;
|
this.$fromUndo = false;
|
||||||
lastUndoRange && this.selection.setSelectionRange(lastUndoRange);
|
lastUndoRange &&
|
||||||
|
!dontSelect &&
|
||||||
|
this.selection.setSelectionRange(lastUndoRange);
|
||||||
|
return lastUndoRange;
|
||||||
},
|
},
|
||||||
|
|
||||||
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
|
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
|
||||||
|
|
|
||||||
|
|
@ -265,20 +265,16 @@ function UndoManagerProxy(undoManager, session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.undo = function() {
|
this.undo = function() {
|
||||||
var u = this.$u;
|
var selectionRange = this.$u.undo(true);
|
||||||
var deltas = u.$undoStack.pop();
|
if (selectionRange) {
|
||||||
if (deltas) {
|
this.$doc.selection.setSelectionRange(selectionRange);
|
||||||
this.$doc.undoChanges(deltas);
|
|
||||||
u.$redoStack.push(deltas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function() {
|
||||||
var u = this.$u;
|
var selectionRange = this.$u.redo(true);
|
||||||
var deltas = u.$redoStack.pop();
|
if (selectionRange) {
|
||||||
if (deltas) {
|
this.$doc.selection.setSelectionRange(selectionRange);
|
||||||
this.$doc.redoChanges(deltas);
|
|
||||||
u.$undoStack.push(deltas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,20 +52,26 @@ var UndoManager = function() {
|
||||||
this.$redoStack = [];
|
this.$redoStack = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
this.undo = function() {
|
this.undo = function(dontSelect) {
|
||||||
var deltas = this.$undoStack.pop();
|
var deltas = this.$undoStack.pop();
|
||||||
|
var undoSelectionRange = null;
|
||||||
if (deltas) {
|
if (deltas) {
|
||||||
this.$doc.undoChanges(deltas);
|
undoSelectionRange =
|
||||||
|
this.$doc.undoChanges(deltas, dontSelect);
|
||||||
this.$redoStack.push(deltas);
|
this.$redoStack.push(deltas);
|
||||||
}
|
}
|
||||||
|
return undoSelectionRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function(dontSelect) {
|
||||||
var deltas = this.$redoStack.pop();
|
var deltas = this.$redoStack.pop();
|
||||||
|
var redoSelectionRange = null;
|
||||||
if (deltas) {
|
if (deltas) {
|
||||||
this.$doc.redoChanges(deltas);
|
redoSelectionRange =
|
||||||
|
this.$doc.redoChanges(deltas, dontSelect);
|
||||||
this.$undoStack.push(deltas);
|
this.$undoStack.push(deltas);
|
||||||
}
|
}
|
||||||
|
return redoSelectionRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reset = function() {
|
this.reset = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue