MCPcopy
hub / github.com/DHTMLX/gantt / findStartLine

Function findStartLine

samples/common/codehighlight/codemirror.js:1255–1270  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

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