(cm, n, precise)
| 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 |
no test coverage detected