Skip to content

Commit 9a843ee

Browse files
committed
Make goLineStart and goLineEnd pass in an explicit bias for skipping atomics
Issue #2635
1 parent 87e0f15 commit 9a843ee

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/codemirror.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,7 +4575,8 @@
45754575
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
45764576
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
45774577
goLineStart: function(cm) {
4578-
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, sel_move);
4578+
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
4579+
{origin: "+move", bias: 1});
45794580
},
45804581
goLineStartSmart: function(cm) {
45814582
cm.extendSelectionsBy(function(range) {
@@ -4588,10 +4589,11 @@
45884589
return Pos(start.line, inWS ? 0 : firstNonWS);
45894590
}
45904591
return start;
4591-
}, sel_move);
4592+
}, {origin: "+move", bias: 1});
45924593
},
45934594
goLineEnd: function(cm) {
4594-
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, sel_move);
4595+
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
4596+
{origin: "+move", bias: -1});
45954597
},
45964598
goLineRight: function(cm) {
45974599
cm.extendSelectionsBy(function(range) {

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,16 @@ testCM("selectionBias", function(cm) {
16131613
eqPos(cm.getCursor(), Pos(0, 3));
16141614
}, {value: "12345"});
16151615

1616+
testCM("selectionHomeEnd", function(cm) {
1617+
cm.markText(Pos(1, 0), Pos(1, 1), {atomic: true, inclusiveLeft: true});
1618+
cm.markText(Pos(1, 3), Pos(1, 4), {atomic: true, inclusiveRight: true});
1619+
cm.setCursor(Pos(1, 2));
1620+
cm.execCommand("goLineStart");
1621+
eqPos(cm.getCursor(), Pos(1, 1));
1622+
cm.execCommand("goLineEnd");
1623+
eqPos(cm.getCursor(), Pos(1, 3));
1624+
}, {value: "ab\ncdef\ngh"});
1625+
16161626
testCM("readOnlyMarker", function(cm) {
16171627
function mark(ll, cl, lr, cr, at) {
16181628
return cm.markText(Pos(ll, cl), Pos(lr, cr),

0 commit comments

Comments
 (0)