Skip to content

Commit

Permalink
Fix #132271
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Sep 10, 2021
1 parent ad67ad4 commit f7bdb7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export class IncludePatternInputWidget extends PatternInputWidget {

setOnlySearchInOpenEditors(value: boolean) {
this.useSearchInEditorsBox.checked = value;
this._onChangeSearchInEditorsBoxEmitter.fire();
}

protected override getSubcontrolsWidth(): number {
Expand Down
15 changes: 13 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);

Expand All @@ -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(
Expand Down

0 comments on commit f7bdb7c

Please sign in to comment.