MCPcopy
hub / github.com/witheve/Eve / clipPos

Function clipPos

src/codemirror.js:2093–2098  ·  view source on GitHub ↗
(doc, pos)

Source from the content-addressed store, hash-verified

2091 // actually exist within the document.
2092 function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
2093 function clipPos(doc, pos) {
2094 if (pos.line < doc.first) return Pos(doc.first, 0);
2095 var last = doc.first + doc.size - 1;
2096 if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
2097 return clipToLen(pos, getLine(doc, pos.line).text.length);
2098 }
2099 function clipToLen(pos, linelen) {
2100 var ch = pos.ch;
2101 if (ch == null || ch > linelen) return Pos(pos.line, linelen);

Callers 13

clipPosArrayFunction · 0.85
filterSelectionChangeFunction · 0.85
movePosFunction · 0.85
estimateCoordsFunction · 0.85
endOperation_finishFunction · 0.85
registerEventHandlersFunction · 0.85
leftButtonSelectFunction · 0.85
extendToFunction · 0.85
loadFileFunction · 0.85
filterChangeFunction · 0.85
codemirror.jsFile · 0.85
markTextSharedFunction · 0.85

Calls 2

getLineFunction · 0.85
clipToLenFunction · 0.85

Tested by

no test coverage detected