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

Function findPosH

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:1449–1477  ·  view source on GitHub ↗
(dir, unit)

Source from the content-addressed store, hash-verified

1447 }
1448
1449 function findPosH(dir, unit) {
1450 var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch;
1451 var lineObj = getLine(line);
1452 function findNextLine() {
1453 for (var l = line + dir, e = dir < 0 ? -1 : doc.size; l != e; l += dir) {
1454 var lo = getLine(l);
1455 if (!lo.hidden) { line = l; lineObj = lo; return true; }
1456 }
1457 }
1458 function moveOnce(boundToLine) {
1459 if (ch == (dir < 0 ? 0 : lineObj.text.length)) {
1460 if (!boundToLine && findNextLine()) ch = dir < 0 ? lineObj.text.length : 0;
1461 else return false;
1462 } else ch += dir;
1463 return true;
1464 }
1465 if (unit == "char") moveOnce();
1466 else if (unit == "column") moveOnce(true);
1467 else if (unit == "word") {
1468 var sawWord = false;
1469 for (;;) {
1470 if (dir < 0) if (!moveOnce()) break;
1471 if (isWordChar(lineObj.text.charAt(ch))) sawWord = true;
1472 else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;}
1473 if (dir > 0) if (!moveOnce()) break;
1474 }
1475 }
1476 return {line: line, ch: ch};
1477 }
1478 function moveH(dir, unit) {
1479 var pos = dir < 0 ? sel.from : sel.to;
1480 if (shiftSelecting || posEq(sel.from, sel.to)) pos = findPosH(dir, unit);

Callers 2

moveHFunction · 0.70
deleteHFunction · 0.70

Calls 3

getLineFunction · 0.70
moveOnceFunction · 0.70
isWordCharFunction · 0.70

Tested by

no test coverage detected