From f7bdb7ce51cb5fcf299e3c99b8ff27537dd18af0 Mon Sep 17 00:00:00 2001 From: Jackson Kearl Date: Thu, 9 Sep 2021 18:15:13 -0700 Subject: [PATCH] Fix #132271 Fix #130412 --- .../contrib/search/browser/patternInputWidget.ts | 1 + .../contrib/search/browser/searchView.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/search/browser/patternInputWidget.ts b/src/vs/workbench/contrib/search/browser/patternInputWidget.ts index 15777a0ed2b25..2f377c1f65d29 100644 --- a/src/vs/workbench/contrib/search/browser/patternInputWidget.ts +++ b/src/vs/workbench/contrib/search/browser/patternInputWidget.ts @@ -209,6 +209,7 @@ export class IncludePatternInputWidget extends PatternInputWidget { setOnlySearchInOpenEditors(value: boolean) { this.useSearchInEditorsBox.checked = value; + this._onChangeSearchInEditorsBoxEmitter.fire(); } protected override getSubcontrolsWidth(): number { diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index b331a2c8fafce..114684221ba37 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -505,7 +505,7 @@ export class SearchView extends ViewPane { private refreshAndUpdateCount(event?: IChangeEvent): void { this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty()); - this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles); + this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles, this.viewModel.searchResult.query?.onlyOpenEditors); return this.refreshTree(event); } @@ -1600,7 +1600,12 @@ export class SearchView extends ViewPane { this.searchExcludePattern.setUseExcludesAndIgnoreFiles(true); } - private updateSearchResultCount(disregardExcludesAndIgnores?: boolean): void { + private onDisableSearchInOpenEditors(): void { + this.toggleQueryDetails(false, true); + this.inputPatternIncludes.setOnlySearchInOpenEditors(false); + } + + private updateSearchResultCount(disregardExcludesAndIgnores?: boolean, onlyOpenEditors?: boolean): void { const fileCount = this.viewModel.searchResult.fileCount(); this.hasSearchResultsKey.set(fileCount > 0); @@ -1618,6 +1623,12 @@ export class SearchView extends ViewPane { dom.append(messageEl, $('span', undefined, excludesDisabledMessage, '(', enableExcludesButton.element, ')')); } + if (onlyOpenEditors) { + const searchingInOpenMessage = ' - ' + nls.localize('onlyOpenEditors', "searching only in open files") + ' '; + const disableOpenEditorsButton = this.messageDisposables.add(new SearchLinkButton(nls.localize('openEditors.disable', "disable"), this.onDisableSearchInOpenEditors.bind(this), nls.localize('disableOpenEditors', "Search in entire workspace"))); + dom.append(messageEl, $('span', undefined, searchingInOpenMessage, '(', disableOpenEditorsButton.element, ')')); + } + dom.append(messageEl, ' - '); const openInEditorTooltip = appendKeyBindingLabel(