Skip to content

Commit 4fb97fe

Browse files
committed
[matchesonscrollbar addon] Support a maxMatches option
1 parent 9af92d9 commit 4fb97fe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

addon/search/matchesonscrollbar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
function SearchAnnotation(cm, query, caseFold, options) {
2121
this.cm = cm;
22+
this.options = options;
2223
var annotateOptions = {listenForChanges: false};
2324
for (var prop in options) annotateOptions[prop] = options[prop];
2425
if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
@@ -46,11 +47,12 @@
4647
if (match.to.line >= this.gap.from) this.matches.splice(i--, 1);
4748
}
4849
var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), this.caseFold);
50+
var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES;
4951
while (cursor.findNext()) {
5052
var match = {from: cursor.from(), to: cursor.to()};
5153
if (match.from.line >= this.gap.to) break;
5254
this.matches.splice(i++, 0, match);
53-
if (this.matches.length > MAX_MATCHES) break;
55+
if (this.matches.length > maxMatches) break;
5456
}
5557
this.gap = null;
5658
};

0 commit comments

Comments
 (0)