MCPcopy
hub / github.com/witheve/Eve / moveVisually

Function moveVisually

src/codemirror.js:8718–8739  ·  view source on GitHub ↗
(line, start, dir, byUnit)

Source from the content-addressed store, hash-verified

8716 // LTR text touch each other. This often requires the cursor offset
8717 // to move more than one unit, in order to visually move one unit.
8718 function moveVisually(line, start, dir, byUnit) {
8719 var bidi = getOrder(line);
8720 if (!bidi) return moveLogically(line, start, dir, byUnit);
8721 var pos = getBidiPartAt(bidi, start), part = bidi[pos];
8722 var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
8723
8724 for (;;) {
8725 if (target > part.from && target < part.to) return target;
8726 if (target == part.from || target == part.to) {
8727 if (getBidiPartAt(bidi, target) == pos) return target;
8728 part = bidi[pos += dir];
8729 return (dir > 0) == part.level % 2 ? part.to : part.from;
8730 } else {
8731 part = bidi[pos += dir];
8732 if (!part) return null;
8733 if ((dir > 0) == part.level % 2)
8734 target = moveInLine(line, part.to, -1, byUnit);
8735 else
8736 target = moveInLine(line, part.from, 1, byUnit);
8737 }
8738 }
8739 }
8740
8741 function moveLogically(line, start, dir, byUnit) {
8742 var target = start + dir;

Callers 1

coordsCharInnerFunction · 0.85

Calls 4

getOrderFunction · 0.85
moveLogicallyFunction · 0.85
getBidiPartAtFunction · 0.85
moveInLineFunction · 0.85

Tested by

no test coverage detected