Skip to content

Commit 9e82c4a

Browse files
authored
Merge pull request microsoft#226913 from microsoft/andreamah/issue226859
Closed notebook search blocks text search
2 parents 3079ca3 + 17ba136 commit 9e82c4a

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,21 @@ export class NotebookSearchService implements INotebookSearchService {
117117
}
118118

119119
private async doesFileExist(includes: string[], folderQueries: IFolderQuery<URI>[], token: CancellationToken): Promise<boolean> {
120-
const promises: Promise<void>[] = includes.map(async includePattern => {
120+
const promises: Promise<boolean>[] = includes.map(async includePattern => {
121121
const query = this.queryBuilder.file(folderQueries.map(e => e.folder), {
122122
includePattern: includePattern.startsWith('/') ? includePattern : '**/' + includePattern, // todo: find cleaner way to ensure that globs match all appropriate filetypes
123-
exists: true
123+
exists: true,
124+
onlyFileScheme: true,
124125
});
125126
return this.searchService.fileSearch(
126127
query,
127128
token
128129
).then((ret) => {
129-
if (!ret.limitHit) {
130-
throw Error('File not found');
131-
}
130+
return !!ret.limitHit;
132131
});
133132
});
134133

135-
return Promise.any(promises).then(() => true).catch(() => false);
134+
return Promise.any(promises);
136135
}
137136

138137
private async getClosedNotebookResults(textQuery: ITextQuery, scannedFiles: ResourceSet, token: CancellationToken): Promise<IClosedNotebookSearchResults> {

src/vs/workbench/services/search/common/queryBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ interface ICommonQueryBuilderOptions {
9292
disregardSearchExcludeSettings?: boolean;
9393
ignoreSymlinks?: boolean;
9494
onlyOpenEditors?: boolean;
95+
onlyFileScheme?: boolean;
9596
}
9697

9798
export interface IFileQueryBuilderOptions extends ICommonQueryBuilderOptions {
@@ -260,7 +261,8 @@ export class QueryBuilder {
260261
excludePattern: excludeSearchPathsInfo.pattern,
261262
includePattern: includeSearchPathsInfo.pattern,
262263
onlyOpenEditors: options.onlyOpenEditors,
263-
maxResults: options.maxResults
264+
maxResults: options.maxResults,
265+
onlyFileScheme: options.onlyFileScheme
264266
};
265267

266268
if (options.onlyOpenEditors) {

src/vs/workbench/services/search/common/search.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export interface ICommonQueryProps<U extends UriComponents> {
100100

101101
maxResults?: number;
102102
usingSearchPaths?: boolean;
103+
onlyFileScheme?: boolean;
103104
}
104105

105106
export interface IFileQueryProps<U extends UriComponents> extends ICommonQueryProps<U> {

src/vs/workbench/services/search/common/searchService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ export class SearchService extends Disposable implements ISearchService {
271271
return [];
272272
}
273273
await Promise.all([...fqs.keys()].map(async scheme => {
274+
if (query.onlyFileScheme && scheme !== Schemas.file) {
275+
return;
276+
}
274277
const schemeFQs = fqs.get(scheme)!;
275278
let provider = this.getSearchProvider(query.type).get(scheme);
276279

0 commit comments

Comments
 (0)