emacs: fix exchangePointAndMark in normal select mode

This commit is contained in:
Robert Krahn 2014-03-24 16:16:54 -07:00
commit ea67201540

View file

@ -481,8 +481,11 @@ exports.handler.addCommands({
exchangePointAndMark: { exchangePointAndMark: {
exec: function (editor, args) { exec: function (editor, args) {
var restoreMarks = []; var restoreMarks = [];
editor.forEachSelection({ if (editor.inMultiSelectMode) editor.forEachSelection({exec: doExchange});
exec: function() { else doExchange();
restoreMarks.reverse().forEach(function(p) { editor.pushEmacsMark(p); });
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function doExchange() {
var sel = editor.selection; var sel = editor.selection;
if (args.count) { // replace mark and point if (args.count) { // replace mark and point
var pos = {row: sel.lead.row, column: sel.lead.column}; var pos = {row: sel.lead.row, column: sel.lead.column};
@ -497,8 +500,6 @@ exports.handler.addCommands({
sel.setSelectionRange(sel.getRange(), !sel.isBackwards()); sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
} }
} }
});
restoreMarks.reverse().forEach(function(p) { editor.pushEmacsMark(p); });
}, },
readOnly: true, readOnly: true,
handlesCount: true, handlesCount: true,