Merge pull request #556 from ajaxorg/select-undo
Added the ability to (temporarily) disable selection of undos
This commit is contained in:
commit
bf263ff375
2 changed files with 11 additions and 2 deletions
|
|
@ -58,6 +58,7 @@ var EditSession = function(text, mode) {
|
||||||
this.$rowCache = [];
|
this.$rowCache = [];
|
||||||
this.$wrapData = [];
|
this.$wrapData = [];
|
||||||
this.$foldData = [];
|
this.$foldData = [];
|
||||||
|
this.$undoSelect = true;
|
||||||
this.$foldData.toString = function() {
|
this.$foldData.toString = function() {
|
||||||
var str = "";
|
var str = "";
|
||||||
this.forEach(function(foldLine) {
|
this.forEach(function(foldLine) {
|
||||||
|
|
@ -653,10 +654,11 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
this.$fromUndo = false;
|
this.$fromUndo = false;
|
||||||
lastUndoRange &&
|
lastUndoRange &&
|
||||||
|
this.$undoSelect &&
|
||||||
!dontSelect &&
|
!dontSelect &&
|
||||||
this.selection.setSelectionRange(lastUndoRange);
|
this.selection.setSelectionRange(lastUndoRange);
|
||||||
return lastUndoRange;
|
return lastUndoRange;
|
||||||
},
|
};
|
||||||
|
|
||||||
this.redoChanges = function(deltas, dontSelect) {
|
this.redoChanges = function(deltas, dontSelect) {
|
||||||
if (!deltas.length)
|
if (!deltas.length)
|
||||||
|
|
@ -674,10 +676,15 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
this.$fromUndo = false;
|
this.$fromUndo = false;
|
||||||
lastUndoRange &&
|
lastUndoRange &&
|
||||||
|
this.$undoSelect &&
|
||||||
!dontSelect &&
|
!dontSelect &&
|
||||||
this.selection.setSelectionRange(lastUndoRange);
|
this.selection.setSelectionRange(lastUndoRange);
|
||||||
return lastUndoRange;
|
return lastUndoRange;
|
||||||
},
|
};
|
||||||
|
|
||||||
|
this.setUndoSelect = function(enable) {
|
||||||
|
this.$undoSelect = enable;
|
||||||
|
};
|
||||||
|
|
||||||
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
|
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
|
||||||
function isInsert(delta) {
|
function isInsert(delta) {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
||||||
var anchor = doc.createAnchor(other.row, other.column);
|
var anchor = doc.createAnchor(other.row, other.column);
|
||||||
_self.others.push(anchor);
|
_self.others.push(anchor);
|
||||||
});
|
});
|
||||||
|
session.setUndoSelect(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showOtherMarkers = function() {
|
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++) {
|
for (var i = 0; i < this.others.length; i++) {
|
||||||
this.others[i].detach();
|
this.others[i].detach();
|
||||||
}
|
}
|
||||||
|
this.session.setUndoSelect(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.cancel = function() {
|
this.cancel = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue