|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import 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'; |
8 | 8 | import { Emitter } from 'vs/base/common/event'; |
9 | 9 | import { combinedDisposable, Disposable, dispose, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle'; |
10 | 10 |
|
11 | | -export interface ISearchOptions { |
12 | | - regex?: boolean; |
13 | | - wholeWord?: boolean; |
14 | | - caseSensitive?: boolean; |
15 | | - incremental?: boolean; |
16 | | - decorations?: ISearchDecorationOptions; |
| 11 | +interface IInternalSearchOptions { |
17 | 12 | noScroll?: boolean; |
18 | 13 | } |
19 | 14 |
|
20 | | -interface ISearchDecorationOptions { |
21 | | - matchBackground?: string; |
22 | | - matchBorder?: string; |
23 | | - matchOverviewRuler: string; |
24 | | - activeMatchBackground?: string; |
25 | | - activeMatchBorder?: string; |
26 | | - activeMatchColorOverviewRuler: string; |
27 | | -} |
28 | | - |
29 | 15 | export interface ISearchPosition { |
30 | 16 | startCol: number; |
31 | 17 | startRow: number; |
@@ -110,7 +96,10 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA |
110 | 96 | this._highlightTimeout = setTimeout(() => { |
111 | 97 | const term = this._cachedSearchTerm; |
112 | 98 | this._cachedSearchTerm = undefined; |
113 | | - this.findPrevious(term!, { ...this._lastSearchOptions, incremental: true, noScroll: true }); |
| 99 | + // Pass noScroll as true for internal incremental update |
| 100 | + this._findPreviousAndSelect(term!, this._lastSearchOptions, { noScroll: true }); |
| 101 | + this._fireResults(this._lastSearchOptions); |
| 102 | + this._cachedSearchTerm = term; |
114 | 103 | }, 200); |
115 | 104 | } |
116 | 105 | } |
@@ -237,7 +226,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA |
237 | 226 | return result; |
238 | 227 | } |
239 | 228 |
|
240 | | - private _findNextAndSelect(term: string, searchOptions?: ISearchOptions): boolean { |
| 229 | + private _findNextAndSelect(term: string, searchOptions?: ISearchOptions, internalSearchOptions?: IInternalSearchOptions): boolean { |
241 | 230 | if (!this._terminal || !term || term.length === 0) { |
242 | 231 | this._terminal?.clearSelection(); |
243 | 232 | this.clearDecorations(); |
@@ -302,7 +291,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA |
302 | 291 | } |
303 | 292 |
|
304 | 293 | // Set selection and scroll if a result was found |
305 | | - return this._selectResult(result, searchOptions?.decorations, searchOptions?.noScroll); |
| 294 | + return this._selectResult(result, searchOptions?.decorations, internalSearchOptions?.noScroll); |
306 | 295 | } |
307 | 296 | /** |
308 | 297 | * Find the previous instance of the term, then scroll to and select it. If it |
@@ -363,7 +352,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA |
363 | 352 | } |
364 | 353 | } |
365 | 354 |
|
366 | | - private _findPreviousAndSelect(term: string, searchOptions?: ISearchOptions): boolean { |
| 355 | + private _findPreviousAndSelect(term: string, searchOptions?: ISearchOptions, internalSearchOptions?: IInternalSearchOptions): boolean { |
367 | 356 | if (!this._terminal) { |
368 | 357 | throw new Error('Cannot use addon until it has been loaded'); |
369 | 358 | } |
@@ -428,7 +417,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA |
428 | 417 | } |
429 | 418 |
|
430 | 419 | // Set selection and scroll if a result was found |
431 | | - return this._selectResult(result, searchOptions?.decorations, searchOptions?.noScroll); |
| 420 | + return this._selectResult(result, searchOptions?.decorations, internalSearchOptions?.noScroll); |
432 | 421 | } |
433 | 422 |
|
434 | 423 | /** |
|
0 commit comments