Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add maxHighlightLength option

  • Loading branch information...
commit ca79fa2066b956bc290abfcee2be6224cbed9a5b 1 parent 1b150c9
@marijnh marijnh authored
Showing with 13 additions and 4 deletions.
  1. +7 −0 doc/manual.html
  2. +6 −4 lib/codemirror.js
View
7 doc/manual.html
@@ -326,6 +326,13 @@ <h2 id="config">Configuration</h2>
document looks. You can set this option to false to disable this
behavior.</dd>
+ <dt id="option_maxHighlightLength"><code>maxHighlightLength (number)</code></dt>
+ <dd>When highlighting long lines, in order to stay responsive,
+ the editor will give up and simply style the rest of the line as
+ plain text when it reaches a certain position. The default is
+ 10000. You can set this to <code>Infinity</code> to turn off
+ this behavior.</dd>
+
<dt id="option_viewportMargin"><code>viewportMargin (integer)</code></dt>
<dd>Specifies the amount of lines that are rendered above and
below the part of the document that's currently scrolled into
View
10 lib/codemirror.js
@@ -3087,6 +3087,7 @@ window.CodeMirror = (function() {
option("pollInterval", 100);
option("undoDepth", 40, function(cm, val){cm.doc.history.undoDepth = val;});
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
+ option("maxHighlightLength", 10000, function(cm){loadMode(cm); cm.refresh();}, true);
option("tabindex", null, function(cm, val) {
cm.display.input.tabIndex = val || "";
@@ -3978,15 +3979,16 @@ window.CodeMirror = (function() {
var flattenSpans = mode.flattenSpans;
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
var curText = "", curStyle = null;
- var stream = new StringStream(text, cm.options.tabSize);
+ var stream = new StringStream(text, cm.options.tabSize), style;
if (text == "" && mode.blankLine) mode.blankLine(state);
while (!stream.eol()) {
- var style = mode.token(stream, state);
- if (stream.pos > 5000) {
+ if (stream.pos > cm.options.maxHighlightLength) {
flattenSpans = false;
// Webkit seems to refuse to render text nodes longer than 57444 characters
stream.pos = Math.min(text.length, stream.start + 50000);
style = null;
+ } else {
+ style = mode.token(stream, state);
}
var substr = stream.current();
stream.start = stream.pos;
@@ -4049,7 +4051,7 @@ window.CodeMirror = (function() {
var mode = cm.doc.mode;
var stream = new StringStream(line.text, cm.options.tabSize);
if (line.text == "" && mode.blankLine) mode.blankLine(state);
- while (!stream.eol() && stream.pos <= 5000) {
+ while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
mode.token(stream, state);
stream.start = stream.pos;
}
Please sign in to comment.
Something went wrong with that request. Please try again.