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"
|
||||
},
|
||||
exchangePointAndMark: {
|
||||
exec: function(editor, args) {
|
||||
var sel = editor.selection;
|
||||
if (args.count) {
|
||||
var pos = editor.getCursorPosition();
|
||||
sel.clearSelection();
|
||||
sel.moveCursorToPosition(editor.popEmacsMark());
|
||||
editor.pushEmacsMark(pos);
|
||||
return;
|
||||
}
|
||||
var lastMark = editor.getLastEmacsMark();
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
sel.selectToPosition(lastMark);
|
||||
return;
|
||||
}
|
||||
sel.setSelectionRange(range, !sel.isBackwards());
|
||||
exec: function (editor, args) {
|
||||
var restoreMarks = [];
|
||||
editor.forEachSelection({
|
||||
exec: function() {
|
||||
var sel = editor.selection;
|
||||
if (args.count) { // replace mark and point
|
||||
var pos = {row: sel.lead.row, column: sel.lead.column};
|
||||
restoreMarks.push(pos);
|
||||
sel.clearSelection();
|
||||
sel.moveCursorToPosition(editor.popEmacsMark());
|
||||
} else if (sel.isEmpty()) { // move to mark, forget point
|
||||
var lastMark = editor.popEmacsMark();
|
||||
restoreMarks.push(lastMark);
|
||||
sel.selectToPosition(lastMark);
|
||||
} else { // just invert selection
|
||||
sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
|
||||
}
|
||||
}
|
||||
});
|
||||
restoreMarks.reverse().forEach(function(p) { editor.pushEmacsMark(p); });
|
||||
},
|
||||
readOnly: true,
|
||||
handlesCount: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue