From 69adc1fa64ae886718fdc4556935d305d4c45d30 Mon Sep 17 00:00:00 2001 From: tisilent Date: Tue, 15 Aug 2023 11:11:03 +0800 Subject: [PATCH 1/2] Find with selected values when reveal TerminalFind --- .../terminalContrib/find/browser/terminalFindWidget.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts b/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts index 780540bc02b..f730c159463 100644 --- a/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts +++ b/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts @@ -81,9 +81,9 @@ export class TerminalFindWidget extends SimpleFindWidget { override reveal(): void { const initialInput = this._instance.hasSelection() && !this._instance.selection!.includes('\n') ? this._instance.selection : undefined; const xterm = this._instance.xterm; - if (xterm && this.inputValue && this.inputValue !== '') { + if (xterm && initialInput && initialInput !== '') { // trigger highlight all matches - this._findPreviousWithEvent(xterm, this.inputValue, { incremental: true, regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue() }).then(foundMatch => { + this._findPreviousWithEvent(xterm, initialInput, { incremental: true, regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue() }).then(foundMatch => { this.updateButtons(foundMatch); this._register(Event.once(xterm.onDidChangeSelection)(() => xterm.clearActiveSearchDecoration())); }); From 004189ef85c8896e694671cc6bedf7ed28eeed31 Mon Sep 17 00:00:00 2001 From: tisilent Date: Wed, 16 Aug 2023 17:15:51 +0800 Subject: [PATCH 2/2] fallback to this.inputValue if initialInput is undefined --- .../terminalContrib/find/browser/terminalFindWidget.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts b/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts index f730c159463..efb9b621568 100644 --- a/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts +++ b/src/vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget.ts @@ -80,17 +80,18 @@ export class TerminalFindWidget extends SimpleFindWidget { override reveal(): void { const initialInput = this._instance.hasSelection() && !this._instance.selection!.includes('\n') ? this._instance.selection : undefined; + const inputValue = initialInput ?? this.inputValue; const xterm = this._instance.xterm; - if (xterm && initialInput && initialInput !== '') { + if (xterm && inputValue && inputValue !== '') { // trigger highlight all matches - this._findPreviousWithEvent(xterm, initialInput, { incremental: true, regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue() }).then(foundMatch => { + this._findPreviousWithEvent(xterm, inputValue, { incremental: true, regex: this._getRegexValue(), wholeWord: this._getWholeWordValue(), caseSensitive: this._getCaseSensitiveValue() }).then(foundMatch => { this.updateButtons(foundMatch); this._register(Event.once(xterm.onDidChangeSelection)(() => xterm.clearActiveSearchDecoration())); }); } this.updateButtons(false); - super.reveal(initialInput); + super.reveal(inputValue); this._findWidgetVisible.set(true); }