@@ -72,6 +72,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
72
72
private _cachedSearchTerm : string | undefined ;
73
73
private _highlightedLines : Set < number > = new Set ( ) ;
74
74
private _highlightDecorations : IHighlight [ ] = [ ] ;
75
+ private _searchResultsWithHighlight : ISearchResult [ ] = [ ] ;
75
76
private _selectedDecoration : MutableDisposable < IMultiHighlight > = this . _register ( new MutableDisposable ( ) ) ;
76
77
private _highlightLimit : number ;
77
78
private _lastSearchOptions : ISearchOptions | undefined ;
@@ -118,6 +119,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
118
119
this . _selectedDecoration . clear ( ) ;
119
120
dispose ( this . _highlightDecorations ) ;
120
121
this . _highlightDecorations = [ ] ;
122
+ this . _searchResultsWithHighlight = [ ] ;
121
123
this . _highlightedLines . clear ( ) ;
122
124
if ( ! retainCachedSearchTerm ) {
123
125
this . _cachedSearchTerm = undefined ;
@@ -167,23 +169,22 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
167
169
// new search, clear out the old decorations
168
170
this . clearDecorations ( true ) ;
169
171
170
- const searchResultsWithHighlight : ISearchResult [ ] = [ ] ;
171
172
let prevResult : ISearchResult | undefined = undefined ;
172
173
let result = this . _find ( term , 0 , 0 , searchOptions ) ;
173
174
while ( result && ( prevResult ?. row !== result . row || prevResult ?. col !== result . col ) ) {
174
- if ( searchResultsWithHighlight . length >= this . _highlightLimit ) {
175
+ if ( this . _searchResultsWithHighlight . length >= this . _highlightLimit ) {
175
176
break ;
176
177
}
177
178
prevResult = result ;
178
- searchResultsWithHighlight . push ( prevResult ) ;
179
+ this . _searchResultsWithHighlight . push ( prevResult ) ;
179
180
result = this . _find (
180
181
term ,
181
182
prevResult . col + prevResult . term . length >= this . _terminal . cols ? prevResult . row + 1 : prevResult . row ,
182
183
prevResult . col + prevResult . term . length >= this . _terminal . cols ? 0 : prevResult . col + 1 ,
183
184
searchOptions
184
185
) ;
185
186
}
186
- for ( const match of searchResultsWithHighlight ) {
187
+ for ( const match of this . _searchResultsWithHighlight ) {
187
188
const decorations = this . _createResultDecorations ( match , searchOptions . decorations ! , false ) ;
188
189
if ( decorations ) {
189
190
for ( const decoration of decorations ) {
@@ -350,15 +351,15 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
350
351
let resultIndex = - 1 ;
351
352
if ( this . _selectedDecoration . value ) {
352
353
const selectedMatch = this . _selectedDecoration . value . match ;
353
- for ( let i = 0 ; i < this . _highlightDecorations . length ; i ++ ) {
354
- const match = this . _highlightDecorations [ i ] . match ;
354
+ for ( let i = 0 ; i < this . _searchResultsWithHighlight . length ; i ++ ) {
355
+ const match = this . _searchResultsWithHighlight [ i ] ;
355
356
if ( match . row === selectedMatch . row && match . col === selectedMatch . col && match . size === selectedMatch . size ) {
356
357
resultIndex = i ;
357
358
break ;
358
359
}
359
360
}
360
361
}
361
- this . _onDidChangeResults . fire ( { resultIndex, resultCount : this . _highlightDecorations . length } ) ;
362
+ this . _onDidChangeResults . fire ( { resultIndex, resultCount : this . _searchResultsWithHighlight . length } ) ;
362
363
}
363
364
}
364
365
0 commit comments