(cm)
| 3959 | } |
| 3960 | |
| 3961 | function highlightWorker(cm) { |
| 3962 | var doc = cm.doc; |
| 3963 | if (doc.highlightFrontier >= cm.display.viewTo) { return } |
| 3964 | var end = +new Date + cm.options.workTime; |
| 3965 | var context = getContextBefore(cm, doc.highlightFrontier); |
| 3966 | var changedLines = []; |
| 3967 | |
| 3968 | doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { |
| 3969 | if (context.line >= cm.display.viewFrom) { // Visible |
| 3970 | var oldStyles = line.styles; |
| 3971 | var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null; |
| 3972 | var highlighted = highlightLine(cm, line, context, true); |
| 3973 | if (resetState) { context.state = resetState; } |
| 3974 | line.styles = highlighted.styles; |
| 3975 | var oldCls = line.styleClasses, newCls = highlighted.classes; |
| 3976 | if (newCls) { line.styleClasses = newCls; } |
| 3977 | else if (oldCls) { line.styleClasses = null; } |
| 3978 | var ischange = !oldStyles || oldStyles.length != line.styles.length || |
| 3979 | oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); |
| 3980 | for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; } |
| 3981 | if (ischange) { changedLines.push(context.line); } |
| 3982 | line.stateAfter = context.save(); |
| 3983 | context.nextLine(); |
| 3984 | } else { |
| 3985 | if (line.text.length <= cm.options.maxHighlightLength) |
| 3986 | { processLine(cm, line.text, context); } |
| 3987 | line.stateAfter = context.line % 5 == 0 ? context.save() : null; |
| 3988 | context.nextLine(); |
| 3989 | } |
| 3990 | if (+new Date > end) { |
| 3991 | startWorker(cm, cm.options.workDelay); |
| 3992 | return true |
| 3993 | } |
| 3994 | }); |
| 3995 | doc.highlightFrontier = context.line; |
| 3996 | doc.modeFrontier = Math.max(doc.modeFrontier, context.line); |
| 3997 | if (changedLines.length) { runInOp(cm, function () { |
| 3998 | for (var i = 0; i < changedLines.length; i++) |
| 3999 | { regLineChange(cm, changedLines[i], "text"); } |
| 4000 | }); } |
| 4001 | } |
| 4002 | |
| 4003 | // DISPLAY DRAWING |
| 4004 |
nothing calls this directly
no test coverage detected