emacs: fix multi select exchangePointAndMark
Conflicts: lib/ace/keyboard/emacs.js
This commit is contained in:
parent
90034c3a44
commit
24f3bab19d
1 changed files with 23 additions and 19 deletions
|
|
@ -479,22 +479,26 @@ exports.handler.addCommands({
|
||||||
multiSelectAction: "forEach"
|
multiSelectAction: "forEach"
|
||||||
},
|
},
|
||||||
exchangePointAndMark: {
|
exchangePointAndMark: {
|
||||||
exec: function(editor, args) {
|
exec: function (editor, args) {
|
||||||
var sel = editor.selection;
|
var restoreMarks = [];
|
||||||
if (args.count) {
|
editor.forEachSelection({
|
||||||
var pos = editor.getCursorPosition();
|
exec: function() {
|
||||||
sel.clearSelection();
|
var sel = editor.selection;
|
||||||
sel.moveCursorToPosition(editor.popEmacsMark());
|
if (args.count) { // replace mark and point
|
||||||
editor.pushEmacsMark(pos);
|
var pos = {row: sel.lead.row, column: sel.lead.column};
|
||||||
return;
|
restoreMarks.push(pos);
|
||||||
}
|
sel.clearSelection();
|
||||||
var lastMark = editor.getLastEmacsMark();
|
sel.moveCursorToPosition(editor.popEmacsMark());
|
||||||
var range = sel.getRange();
|
} else if (sel.isEmpty()) { // move to mark, forget point
|
||||||
if (range.isEmpty()) {
|
var lastMark = editor.popEmacsMark();
|
||||||
sel.selectToPosition(lastMark);
|
restoreMarks.push(lastMark);
|
||||||
return;
|
sel.selectToPosition(lastMark);
|
||||||
}
|
} else { // just invert selection
|
||||||
sel.setSelectionRange(range, !sel.isBackwards());
|
sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
restoreMarks.reverse().forEach(function(p) { editor.pushEmacsMark(p); });
|
||||||
},
|
},
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
handlesCount: true,
|
handlesCount: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue