MCPcopy Create free account
hub / github.com/TruthHun/BookStack / clipPos

Function clipPos

static/mergely/lib/codemirror.js:2088–2093  ·  view source on GitHub ↗
(doc, pos)

Source from the content-addressed store, hash-verified

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

Callers 13

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

Calls 2

getLineFunction · 0.70
clipToLenFunction · 0.70

Tested by

no test coverage detected