Skip to content

Commit 00e4259

Browse files
committed
In setSelections, default primary to old primary if not given
This makes it easier to update selections by mapping over them.
1 parent 2007b3c commit 00e4259

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

keymap/sublime.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@
7373
map["Shift-Tab"] = "indentLess";
7474

7575
cmds[map[ctrl + "L"] = "selectLine"] = function(cm) {
76-
var ranges = cm.listSelections(), prim = cm.getCursor(), primIndex, extended = [];
76+
var ranges = cm.listSelections(), extended = [];
7777
for (var i = 0; i < ranges.length; i++) {
7878
var range = ranges[i];
79-
if (range.head == prim) primIndex = i;
8079
extended.push({anchor: Pos(range.from().line, 0),
8180
head: Pos(range.to().line + 1, 0)});
8281
}
83-
cm.setSelections(extended, primIndex);
82+
cm.setSelections(extended);
8483
};
8584

8685
function wordAt(cm, pos) {

lib/codemirror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6068,7 +6068,7 @@
60686068
for (var i = 0, out = []; i < ranges.length; i++)
60696069
out[i] = new Range(clipPos(this, ranges[i].anchor),
60706070
clipPos(this, ranges[i].head));
6071-
if (primary == null) primary = ranges.length - 1;
6071+
if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
60726072
setSelection(this, normalizeSelection(out, primary), options);
60736073
}),
60746074
addSelection: docMethodOp(function(anchor, head, options) {

0 commit comments

Comments
 (0)