(cm, n, precise)
| 120 | } |
| 121 | |
| 122 | export 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 |
no test coverage detected