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