MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / clipToLen

Function clipToLen

static/js/codemirror/codemirror.js:2286–2291  ·  view source on GitHub ↗
(pos, linelen)

Source from the content-addressed store, hash-verified

2284 return clipToLen(pos, getLine(doc, pos.line).text.length);
2285 }
2286 function clipToLen(pos, linelen) {
2287 var ch = pos.ch;
2288 if (ch == null || ch > linelen) return Pos(pos.line, linelen);
2289 else if (ch < 0) return Pos(pos.line, 0);
2290 else return pos;
2291 }
2292 function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
2293
2294 // If shift is held, this will move the selection anchor. Otherwise,

Callers 2

clipPostChangeFunction · 0.85
clipPosFunction · 0.85

Calls 1

PosFunction · 0.85

Tested by

no test coverage detected