MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / getContextBefore

Function getContextBefore

lib/web/CodeMirror/src/line/highlight.js:122–137  ·  view source on GitHub ↗
(cm, n, precise)

Source from the content-addressed store, hash-verified

120}
121
122export function getContextBefore(cm, n, precise) {
123 let doc = cm.doc, display = cm.display
124 if (!doc.mode.startState) return new Context(doc, true, n)
125 let start = findStartLine(cm, n, precise)
126 let saved = start > doc.first && getLine(doc, start - 1).stateAfter
127 let context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start)
128
129 doc.iter(start, n, line => {
130 processLine(cm, line.text, context)
131 let pos = context.line
132 line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null
133 context.nextLine()
134 })
135 if (precise) doc.modeFrontier = context.line
136 return context
137}
138
139// Lightweight form of highlight -- proceed over this line and
140// update state, but don't save a style array. Used for lines that

Callers 5

highlightWorkerFunction · 0.90
indentLineFunction · 0.90
methods.jsFile · 0.90
getLineStylesFunction · 0.70
takeTokenFunction · 0.70

Calls 7

getLineFunction · 0.90
startStateFunction · 0.90
fromSavedMethod · 0.80
nextLineMethod · 0.80
findStartLineFunction · 0.70
processLineFunction · 0.70
saveMethod · 0.45

Tested by

no test coverage detected