Merge pull request #556 from ajaxorg/select-undo

Added the ability to (temporarily) disable selection of undos
This commit is contained in:
Fabian Jakobs 2011-12-05 09:04:04 -08:00
commit bf263ff375
2 changed files with 11 additions and 2 deletions

View file

@ -58,6 +58,7 @@ var EditSession = function(text, mode) {
this.$rowCache = [];
this.$wrapData = [];
this.$foldData = [];
this.$undoSelect = true;
this.$foldData.toString = function() {
var str = "";
this.forEach(function(foldLine) {
@ -653,10 +654,11 @@ var EditSession = function(text, mode) {
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
},
};
this.redoChanges = function(deltas, dontSelect) {
if (!deltas.length)
@ -674,10 +676,15 @@ var EditSession = function(text, mode) {
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
},
};
this.setUndoSelect = function(enable) {
this.$undoSelect = enable;
};
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) {

View file

@ -86,6 +86,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
var anchor = doc.createAnchor(other.row, other.column);
_self.others.push(anchor);
});
session.setUndoSelect(false);
};
this.showOtherMarkers = function() {
@ -189,6 +190,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
for (var i = 0; i < this.others.length; i++) {
this.others[i].detach();
}
this.session.setUndoSelect(true);
};
this.cancel = function() {