MCPcopy Create free account
hub / github.com/TruthHun/BookStack / moveVisually

Function moveVisually

static/mergely/lib/codemirror.js:8686–8707  ·  view source on GitHub ↗
(line, start, dir, byUnit)

Source from the content-addressed store, hash-verified

8684 // LTR text touch each other. This often requires the cursor offset
8685 // to move more than one unit, in order to visually move one unit.
8686 function moveVisually(line, start, dir, byUnit) {
8687 var bidi = getOrder(line);
8688 if (!bidi) return moveLogically(line, start, dir, byUnit);
8689 var pos = getBidiPartAt(bidi, start), part = bidi[pos];
8690 var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
8691
8692 for (;;) {
8693 if (target > part.from && target < part.to) return target;
8694 if (target == part.from || target == part.to) {
8695 if (getBidiPartAt(bidi, target) == pos) return target;
8696 part = bidi[pos += dir];
8697 return (dir > 0) == part.level % 2 ? part.to : part.from;
8698 } else {
8699 part = bidi[pos += dir];
8700 if (!part) return null;
8701 if ((dir > 0) == part.level % 2)
8702 target = moveInLine(line, part.to, -1, byUnit);
8703 else
8704 target = moveInLine(line, part.from, 1, byUnit);
8705 }
8706 }
8707 }
8708
8709 function moveLogically(line, start, dir, byUnit) {
8710 var target = start + dir;

Callers 1

coordsCharInnerFunction · 0.70

Calls 4

getOrderFunction · 0.70
moveLogicallyFunction · 0.70
getBidiPartAtFunction · 0.70
moveInLineFunction · 0.70

Tested by

no test coverage detected