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

Function clipPos

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:1440–1447  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

1438
1439 function clipLine(n) {return Math.max(0, Math.min(n, doc.size-1));}
1440 function clipPos(pos) {
1441 if (pos.line < 0) return {line: 0, ch: 0};
1442 if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc.size-1).text.length};
1443 var ch = pos.ch, linelen = getLine(pos.line).text.length;
1444 if (ch == null || ch > linelen) return {line: pos.line, ch: linelen};
1445 else if (ch < 0) return {line: pos.line, ch: 0};
1446 else return pos;
1447 }
1448
1449 function findPosH(dir, unit) {
1450 var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch;

Callers 10

CodeMirrorFunction · 0.70
loadFileFunction · 0.70
unredoHelperFunction · 0.70
replaceRangeFunction · 0.70
setSelectionUserFunction · 0.70
setCursorFunction · 0.70
selectLineFunction · 0.70
markTextFunction · 0.70
setBookmarkFunction · 0.70
findMarksAtFunction · 0.70

Calls 1

getLineFunction · 0.70

Tested by

no test coverage detected