prevent higlight_word from freezing the browser on long lines
This commit is contained in:
parent
3f8aa00d23
commit
a334a64691
1 changed files with 5 additions and 0 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue