44 */
55
66import type { Terminal , IDisposable , ITerminalAddon , IDecoration } from '@xterm/xterm' ;
7- import type { SearchAddon as ISearchApi } from '@xterm/addon-search' ;
7+ import type { SearchAddon as ISearchApi , ISearchOptions , ISearchDecorationOptions } from '@xterm/addon-search' ;
88import { Emitter , Event } from 'vs/base/common/event' ;
99import { combinedDisposable , Disposable , dispose , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
1010
11- export interface ISearchOptions {
12- regex ?: boolean ;
13- wholeWord ?: boolean ;
14- caseSensitive ?: boolean ;
15- incremental ?: boolean ;
16- decorations ?: ISearchDecorationOptions ;
11+ interface IInternalSearchOptions {
1712 noScroll ?: boolean ;
1813}
1914
20- interface ISearchDecorationOptions {
21- matchBackground ?: string ;
22- matchBorder ?: string ;
23- matchOverviewRuler : string ;
24- activeMatchBackground ?: string ;
25- activeMatchBorder ?: string ;
26- activeMatchColorOverviewRuler : string ;
27- }
28-
2915export interface ISearchPosition {
3016 startCol : number ;
3117 startRow : number ;
@@ -136,7 +122,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
136122 this . _highlightTimeout = setTimeout ( ( ) => {
137123 const term = this . _cachedSearchTerm ;
138124 this . _cachedSearchTerm = undefined ;
139- this . findPrevious ( term ! , { ...this . _lastSearchOptions , incremental : true , noScroll : true } ) ;
125+ this . findPrevious ( term ! , { ...this . _lastSearchOptions , incremental : true } , { noScroll : true } ) ;
140126 } , 200 ) ;
141127 }
142128 }
@@ -163,7 +149,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
163149 * @param searchOptions Search options.
164150 * @returns Whether a result was found.
165151 */
166- public findNext ( term : string , searchOptions ?: ISearchOptions ) : boolean {
152+ public findNext ( term : string , searchOptions ?: ISearchOptions , internalSearchOptions ?: IInternalSearchOptions ) : boolean {
167153 if ( ! this . _terminal ) {
168154 throw new Error ( 'Cannot use addon until it has been loaded' ) ;
169155 }
@@ -175,7 +161,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
175161 }
176162 }
177163
178- const found = this . _findNextAndSelect ( term , searchOptions ) ;
164+ const found = this . _findNextAndSelect ( term , searchOptions , internalSearchOptions ) ;
179165 this . _fireResults ( searchOptions ) ;
180166 this . _cachedSearchTerm = term ;
181167
@@ -263,7 +249,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
263249 return result ;
264250 }
265251
266- private _findNextAndSelect ( term : string , searchOptions ?: ISearchOptions ) : boolean {
252+ private _findNextAndSelect ( term : string , searchOptions ?: ISearchOptions , internalSearchOptions ?: IInternalSearchOptions ) : boolean {
267253 if ( ! this . _terminal || ! term || term . length === 0 ) {
268254 this . _terminal ?. clearSelection ( ) ;
269255 this . clearDecorations ( ) ;
@@ -328,7 +314,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
328314 }
329315
330316 // Set selection and scroll if a result was found
331- return this . _selectResult ( result , searchOptions ?. decorations , searchOptions ?. noScroll ) ;
317+ return this . _selectResult ( result , searchOptions ?. decorations , internalSearchOptions ?. noScroll ) ;
332318 }
333319 /**
334320 * Find the previous instance of the term, then scroll to and select it. If it
@@ -337,7 +323,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
337323 * @param searchOptions Search options.
338324 * @returns Whether a result was found.
339325 */
340- public findPrevious ( term : string , searchOptions ?: ISearchOptions ) : boolean {
326+ public findPrevious ( term : string , searchOptions ?: ISearchOptions , internalSearchOptions ?: IInternalSearchOptions ) : boolean {
341327 if ( ! this . _terminal ) {
342328 throw new Error ( 'Cannot use addon until it has been loaded' ) ;
343329 }
@@ -349,7 +335,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
349335 }
350336 }
351337
352- const found = this . _findPreviousAndSelect ( term , searchOptions ) ;
338+ const found = this . _findPreviousAndSelect ( term , searchOptions , internalSearchOptions ) ;
353339 this . _fireResults ( searchOptions ) ;
354340 this . _cachedSearchTerm = term ;
355341
@@ -389,7 +375,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
389375 }
390376 }
391377
392- private _findPreviousAndSelect ( term : string , searchOptions ?: ISearchOptions ) : boolean {
378+ private _findPreviousAndSelect ( term : string , searchOptions ?: ISearchOptions , internalSearchOptions ?: IInternalSearchOptions ) : boolean {
393379 if ( ! this . _terminal ) {
394380 throw new Error ( 'Cannot use addon until it has been loaded' ) ;
395381 }
@@ -454,7 +440,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
454440 }
455441
456442 // Set selection and scroll if a result was found
457- return this . _selectResult ( result , searchOptions ?. decorations , searchOptions ?. noScroll ) ;
443+ return this . _selectResult ( result , searchOptions ?. decorations , internalSearchOptions ?. noScroll ) ;
458444 }
459445
460446 /**
0 commit comments