MCPcopy Index your code
hub / github.com/csev/py4e / moveVisually

Function moveVisually

tools/pythonauto/static/codemirror/codemirror.js:5898–5919  ·  view source on GitHub ↗
(line, start, dir, byUnit)

Source from the content-addressed store, hash-verified

5896 // other. This often requires the cursor offset to move more than
5897 // one unit, in order to visually move one unit.
5898 function moveVisually(line, start, dir, byUnit) {
5899 var bidi = getOrder(line);
5900 if (!bidi) return moveLogically(line, start, dir, byUnit);
5901 var pos = getBidiPartAt(bidi, start), part = bidi[pos];
5902 var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
5903
5904 for (;;) {
5905 if (target > part.from && target < part.to) return target;
5906 if (target == part.from || target == part.to) {
5907 if (getBidiPartAt(bidi, target) == pos) return target;
5908 part = bidi[pos += dir];
5909 return (dir > 0) == part.level % 2 ? part.to : part.from;
5910 } else {
5911 part = bidi[pos += dir];
5912 if (!part) return null;
5913 if ((dir > 0) == part.level % 2)
5914 target = moveInLine(line, part.to, -1, byUnit);
5915 else
5916 target = moveInLine(line, part.from, 1, byUnit);
5917 }
5918 }
5919 }
5920
5921 function moveLogically(line, start, dir, byUnit) {
5922 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