@@ -122,15 +122,7 @@ export class SearchAddon implements ITerminalAddon {
122122 if ( searchOptions ?. decorations ) {
123123 this . _highlightAllMatches ( term , searchOptions ) ;
124124 }
125- const next = this . _findNextAndSelect ( term , searchOptions ) ;
126- if ( searchOptions ?. decorations ) {
127- if ( next && this . _resultIndex !== undefined && this . _searchResults ?. size ) {
128- this . _onDidChangeResults . fire ( { resultIndex : this . _resultIndex , resultCount : this . _searchResults . size } ) ;
129- } else {
130- this . _onDidChangeResults . fire ( undefined ) ;
131- }
132- }
133- return next ;
125+ return this . _fireResults ( this . _findNextAndSelect ( term , searchOptions ) , searchOptions ) ;
134126 }
135127
136128 private _highlightAllMatches ( term : string , searchOptions : ISearchOptions ) : void {
@@ -157,6 +149,11 @@ export class SearchAddon implements ITerminalAddon {
157149 result . col + result . term . length >= this . _terminal . cols ? 0 : result . col + 1 ,
158150 searchOptions
159151 ) ;
152+ if ( this . _searchResults . size > 2000 ) {
153+ this . clearDecorations ( ) ;
154+ this . _resultIndex = - 1 ;
155+ return ;
156+ }
160157 }
161158 this . _searchResults . forEach ( result => {
162159 const resultDecoration = this . _createResultDecoration ( result , searchOptions . decorations ! ) ;
@@ -300,15 +297,20 @@ export class SearchAddon implements ITerminalAddon {
300297 if ( searchOptions ?. decorations ) {
301298 this . _highlightAllMatches ( term , searchOptions ) ;
302299 }
303- const previous = this . _findPreviousAndSelect ( term , searchOptions ) ;
300+ return this . _fireResults ( this . _findPreviousAndSelect ( term , searchOptions ) , searchOptions ) ;
301+ }
302+
303+ private _fireResults ( found : boolean , searchOptions ?: ISearchOptions ) : boolean {
304304 if ( searchOptions ?. decorations ) {
305- if ( previous && this . _resultIndex !== undefined && this . _searchResults ?. size ) {
305+ if ( found && this . _resultIndex !== undefined && this . _searchResults ?. size ) {
306306 this . _onDidChangeResults . fire ( { resultIndex : this . _resultIndex , resultCount : this . _searchResults . size } ) ;
307+ } else if ( this . _resultIndex === - 1 ) {
308+ this . _onDidChangeResults . fire ( { resultIndex : - 1 , resultCount : - 1 } ) ;
307309 } else {
308310 this . _onDidChangeResults . fire ( undefined ) ;
309311 }
310312 }
311- return previous ;
313+ return found ;
312314 }
313315
314316 private _findPreviousAndSelect ( term : string , searchOptions ?: ISearchOptions ) : boolean {
0 commit comments