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

Function findStartLine

static/mergely/lib/codemirror.js:2480–2494  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

2478 // smallest indentation, which tends to need the least context to
2479 // parse correctly.
2480 function findStartLine(cm, n, precise) {
2481 var minindent, minline, doc = cm.doc;
2482 var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
2483 for (var search = n; search > lim; --search) {
2484 if (search <= doc.first) return doc.first;
2485 var line = getLine(doc, search - 1);
2486 if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
2487 var indented = countColumn(line.text, null, cm.options.tabSize);
2488 if (minline == null || minindent > indented) {
2489 minline = search - 1;
2490 minindent = indented;
2491 }
2492 }
2493 return minline;
2494 }
2495
2496 function getStateBefore(cm, n, precise) {
2497 var doc = cm.doc, display = cm.display;

Callers 1

getStateBeforeFunction · 0.70

Calls 1

getLineFunction · 0.70

Tested by

no test coverage detected