MCPcopy
hub / github.com/csev/py4e / clipPos

Function clipPos

tools/pythonauto/static/codemirrorepl/codemirror.js:1020–1025  ·  view source on GitHub ↗
(doc, pos)

Source from the content-addressed store, hash-verified

1018 // actually exist within the document.
1019 function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
1020 function clipPos(doc, pos) {
1021 if (pos.line < doc.first) return Pos(doc.first, 0);
1022 var last = doc.first + doc.size - 1;
1023 if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
1024 return clipToLen(pos, getLine(doc, pos.line).text.length);
1025 }
1026 function clipToLen(pos, linelen) {
1027 var ch = pos.ch;
1028 if (ch == null || ch > linelen) return Pos(pos.line, linelen);

Callers 11

clipPosArrayFunction · 0.70
filterSelectionChangeFunction · 0.70
skipAtomicFunction · 0.70
estimateCoordsFunction · 0.70
endOperationFunction · 0.70
leftButtonSelectFunction · 0.70
extendToFunction · 0.70
loadFileFunction · 0.70
filterChangeFunction · 0.70
codemirror.jsFile · 0.70
markTextSharedFunction · 0.70

Calls 3

PosFunction · 0.85
getLineFunction · 0.70
clipToLenFunction · 0.70

Tested by

no test coverage detected