@@ -7,6 +7,7 @@ import type { Terminal, IDisposable, ITerminalAddon, IDecoration } from '@xterm/
77import type { SearchAddon as ISearchApi , ISearchOptions , ISearchDecorationOptions } from '@xterm/addon-search' ;
88import { Emitter , Event } from 'vs/base/common/event' ;
99import { Disposable , dispose , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
10+ import { disposableTimeout } from 'vs/base/common/async' ;
1011import { SearchLineCache } from './SearchLineCache' ;
1112
1213interface IInternalSearchOptions {
@@ -34,8 +35,6 @@ export interface ISearchResult {
3435 size : number ;
3536}
3637
37-
38-
3938interface IHighlight extends IDisposable {
4039 decoration : IDecoration ;
4140 match : ISearchResult ;
@@ -57,8 +56,6 @@ const enum Constants {
5756 */
5857 NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?' ,
5958
60-
61-
6259 /**
6360 * Default maximum number of search results to highlight simultaneously. This limit prevents
6461 * performance degradation when searching for very common terms that would result in excessive
@@ -73,10 +70,10 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
7370 private _highlightedLines : Set < number > = new Set ( ) ;
7471 private _highlightDecorations : IHighlight [ ] = [ ] ;
7572 private _searchResultsWithHighlight : ISearchResult [ ] = [ ] ;
76- private _selectedDecoration : MutableDisposable < IMultiHighlight > = this . _register ( new MutableDisposable ( ) ) ;
73+ private _selectedDecoration = this . _register ( new MutableDisposable < IMultiHighlight > ( ) ) ;
7774 private _highlightLimit : number ;
7875 private _lastSearchOptions : ISearchOptions | undefined ;
79- private _highlightTimeout : number | undefined ;
76+ private _highlightTimeout = this . _register ( new MutableDisposable < IDisposable > ( ) ) ;
8077 private _lineCache = this . _register ( new MutableDisposable < SearchLineCache > ( ) ) ;
8178
8279 private readonly _onDidChangeResults = this . _register ( new Emitter < ISearchResultChangeEvent > ( ) ) ;
@@ -97,11 +94,9 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
9794 }
9895
9996 private _updateMatches ( ) : void {
100- if ( this . _highlightTimeout ) {
101- window . clearTimeout ( this . _highlightTimeout ) ;
102- }
97+ this . _highlightTimeout . clear ( ) ;
10398 if ( this . _cachedSearchTerm && this . _lastSearchOptions ?. decorations ) {
104- this . _highlightTimeout = setTimeout ( ( ) => {
99+ this . _highlightTimeout . value = disposableTimeout ( ( ) => {
105100 const term = this . _cachedSearchTerm ;
106101 this . _cachedSearchTerm = undefined ;
107102 this . findPrevious ( term ! , { ...this . _lastSearchOptions , incremental : true } , { noScroll : true } ) ;
0 commit comments