MCPcopy
hub / github.com/agentejo/cockpit / findStartLine

Function findStartLine

assets/lib/codemirror/lib/codemirror.js:1258–1273  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

1256 // smallest indentation, which tends to need the least context to
1257 // parse correctly.
1258 function findStartLine(cm, n, precise) {
1259 var minindent, minline, doc = cm.doc;
1260 var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
1261 for (var search = n; search > lim; --search) {
1262 if (search <= doc.first) { return doc.first }
1263 var line = getLine(doc, search - 1), after = line.stateAfter;
1264 if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
1265 { return search }
1266 var indented = countColumn(line.text, null, cm.options.tabSize);
1267 if (minline == null || minindent > indented) {
1268 minline = search - 1;
1269 minindent = indented;
1270 }
1271 }
1272 return minline
1273 }
1274
1275 function retreatFrontier(doc, n) {
1276 doc.modeFrontier = Math.min(doc.modeFrontier, n);

Callers 1

getContextBeforeFunction · 0.85

Calls 2

getLineFunction · 0.85
countColumnFunction · 0.85

Tested by

no test coverage detected