MCPcopy Create free account
hub / github.com/breck7/scroll / clipPos

Function clipPos

external/.scrollLibs.js:1118–1127  ·  view source on GitHub ↗
(doc, pos)

Source from the content-addressed store, hash-verified

1116 return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))
1117 }
1118 function clipPos(doc, pos) {
1119 if (pos.line < doc.first) {
1120 return Pos(doc.first, 0)
1121 }
1122 var last = doc.first + doc.size - 1
1123 if (pos.line > last) {
1124 return Pos(last, getLine(doc, last).text.length)
1125 }
1126 return clipToLen(pos, getLine(doc, pos.line).text.length)
1127 }
1128 function clipToLen(pos, linelen) {
1129 var ch = pos.ch
1130 if (ch == null || ch > linelen) {

Callers 14

clipPosArrayFunction · 0.85
takeTokenFunction · 0.85
estimateCoordsFunction · 0.85
endOperation_finishFunction · 0.85
filterSelectionChangeFunction · 0.85
movePosFunction · 0.85
filterChangeFunction · 0.85
markTextSharedFunction · 0.85
.scrollLibs.jsFile · 0.85
loadFileFunction · 0.85
rangeForUnitFunction · 0.85
extendToFunction · 0.85

Calls 3

PosFunction · 0.85
getLineFunction · 0.85
clipToLenFunction · 0.85

Tested by

no test coverage detected