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

Function getStateBefore

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

Source from the content-addressed store, hash-verified

2494 }
2495
2496 function getStateBefore(cm, n, precise) {
2497 var doc = cm.doc, display = cm.display;
2498 if (!doc.mode.startState) return true;
2499 var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
2500 if (!state) state = startState(doc.mode);
2501 else state = copyState(doc.mode, state);
2502 doc.iter(pos, n, function(line) {
2503 processLine(cm, line.text, state);
2504 var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
2505 line.stateAfter = save ? copyState(doc.mode, state) : null;
2506 ++pos;
2507 });
2508 if (precise) doc.frontier = pos;
2509 return state;
2510 }
2511
2512 // POSITION MEASUREMENT
2513

Callers 5

highlightWorkerFunction · 0.70
indentLineFunction · 0.70
codemirror.jsFile · 0.70
takeTokenFunction · 0.70
getLineStylesFunction · 0.70

Calls 5

startStateFunction · 0.85
copyStateFunction · 0.85
findStartLineFunction · 0.70
getLineFunction · 0.70
processLineFunction · 0.70

Tested by

no test coverage detected