Skip to content

Commit

Permalink
When skipping atomic marks, only use near side when on same line
Browse files Browse the repository at this point in the history
Which is kind of arbitrary but seems to give less surprising
results.

Issue #3658
  • Loading branch information
marijnh committed Nov 25, 2015
1 parent f14b2f8 commit 1fae537
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2251,13 +2251,13 @@
if (oldPos) {
var near = m.find(dir < 0 ? 1 : -1), diff;
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft) near = movePos(doc, near, -dir, line);
if (near && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
return skipAtomicInner(doc, near, oldPos, dir, mayClear);
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
return skipAtomicInner(doc, near, pos, dir, mayClear);
}

var far = m.find(dir < 0 ? -1 : 1);
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight) far = movePos(doc, far, dir, line);
return far ? skipAtomicInner(doc, far, oldPos, dir, mayClear) : null;
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
}
}
return pos;
Expand Down
2 changes: 0 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,8 +1637,6 @@ testCM("atomicMarker", function(cm) {
m = atom(1, 1, 3, 8);
cm.setCursor(Pos(0, 0));
cm.setCursor(Pos(2, 0));
eqPos(cm.getCursor(), Pos(1, 1));
cm.execCommand("goCharRight");
eqPos(cm.getCursor(), Pos(3, 8));
cm.execCommand("goCharLeft");
eqPos(cm.getCursor(), Pos(1, 1));
Expand Down

0 comments on commit 1fae537

Please sign in to comment.