diff --git a/lib/ace/search_highlight.js b/lib/ace/search_highlight.js index 8f2f5102..64cd43b7 100644 --- a/lib/ace/search_highlight.js +++ b/lib/ace/search_highlight.js @@ -42,6 +42,9 @@ var SearchHighlight = function(regExp, clazz, type) { }; (function() { + // needed to prevent long lines from freezing the browser + this.MAX_RANGES = 500; + this.setRegexp = function(regExp) { if (this.regExp+"" == regExp+"") return; @@ -58,6 +61,8 @@ var SearchHighlight = function(regExp, clazz, type) { var ranges = this.cache[i]; if (ranges == null) { ranges = lang.getMatchOffsets(session.getLine(i), this.regExp); + if (ranges.length > this.MAX_RANGES) + ranges = ranges.slice(0, this.MAX_RANGES); ranges = ranges.map(function(match) { return new Range(i, match.offset, i, match.offset + match.length); });