MCPcopy Create free account
hub / github.com/breck7/scroll / getContextBefore

Function getContextBefore

external/.scrollLibs.js:2567–2587  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

2565 }
2566
2567 function getContextBefore(cm, n, precise) {
2568 var doc = cm.doc,
2569 display = cm.display
2570 if (!doc.mode.startState) {
2571 return new Context(doc, true, n)
2572 }
2573 var start = findStartLine(cm, n, precise)
2574 var saved = start > doc.first && getLine(doc, start - 1).stateAfter
2575 var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start)
2576
2577 doc.iter(start, n, function (line) {
2578 processLine(cm, line.text, context)
2579 var pos = context.line
2580 line.stateAfter = pos == n - 1 || pos % 5 == 0 || (pos >= display.viewFrom && pos < display.viewTo) ? context.save() : null
2581 context.nextLine()
2582 })
2583 if (precise) {
2584 doc.modeFrontier = context.line
2585 }
2586 return context
2587 }
2588
2589 // Lightweight form of highlight -- proceed over this line and
2590 // update state, but don't save a style array. Used for lines that

Callers 5

getLineStylesFunction · 0.85
takeTokenFunction · 0.85
highlightWorkerFunction · 0.85
indentLineFunction · 0.85
addEditorMethodsFunction · 0.85

Calls 4

findStartLineFunction · 0.85
getLineFunction · 0.85
startStateFunction · 0.85
processLineFunction · 0.85

Tested by

no test coverage detected