MCPcopy
hub / github.com/pandao/editor.md / getStateBefore

Function getStateBefore

lib/codemirror/lib/codemirror.js:2392–2406  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

2390 }
2391
2392 function getStateBefore(cm, n, precise) {
2393 var doc = cm.doc, display = cm.display;
2394 if (!doc.mode.startState) return true;
2395 var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
2396 if (!state) state = startState(doc.mode);
2397 else state = copyState(doc.mode, state);
2398 doc.iter(pos, n, function(line) {
2399 processLine(cm, line.text, state);
2400 var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
2401 line.stateAfter = save ? copyState(doc.mode, state) : null;
2402 ++pos;
2403 });
2404 if (precise) doc.frontier = pos;
2405 return state;
2406 }
2407
2408 // POSITION MEASUREMENT
2409

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…