Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook shows up in search results while not in include files #200858

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/note
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { INotebookSearchService } from 'vs/workbench/contrib/search/common/notebookSearch';
import { INotebookCellMatchWithModel, INotebookFileMatchWithModel, contentMatchesToTextSearchMatches, webviewMatchesToTextSearchMatches } from 'vs/workbench/contrib/search/browser/notebookSearch/searchNotebookHelpers';
import { ITextQuery, QueryType, ISearchProgressItem, ISearchComplete, ISearchConfigurationProperties } from 'vs/workbench/services/search/common/search';
import { ITextQuery, QueryType, ISearchProgressItem, ISearchComplete, ISearchConfigurationProperties, pathIncludedInQuery } from 'vs/workbench/services/search/common/search';
import * as arrays from 'vs/base/common/arrays';
import { isNumber } from 'vs/base/common/types';
import { IEditorResolverService } from 'vs/workbench/services/editor/common/editorResolverService';
Expand Down Expand Up @@ -137,7 +137,7 @@ export class NotebookSearchService implements INotebookSearchService {
const promises: Promise<{
results: INotebookFileMatchNoModel<URI>[];
limitHit: boolean;
}>[] = [];
} | undefined>[] = [];

contributedNotebookTypes.forEach((notebook) => {
promises.push((async () => {
Expand All @@ -147,7 +147,7 @@ export class NotebookSearchService implements INotebookSearchService {
});

const start = Date.now();
const searchComplete = (await Promise.all(promises));
const searchComplete = arrays.coalesce(await Promise.all(promises));
const results = searchComplete.flatMap(e => e.results);
let limitHit = searchComplete.some(e => e.limitHit);

Expand Down Expand Up @@ -186,6 +186,12 @@ export class NotebookSearchService implements INotebookSearchService {
continue;
}
const askMax = isNumber(query.maxResults) ? query.maxResults + 1 : Number.MAX_SAFE_INTEGER;
const uri = widget.viewModel!.uri;

if (!pathIncludedInQuery(query, uri.fsPath)) {
continue;
}

let matches = await widget
.find(query.contentPattern.pattern, {
regex: query.contentPattern.isRegExp,
Expand All @@ -197,7 +203,6 @@ export class NotebookSearchService implements INotebookSearchService {
includeOutput: query.contentPattern.notebookInfo?.isInNotebookCellOutput ?? true,
}, token, false, true, searchID);

const uri = widget.viewModel!.uri;

if (matches.length) {
if (askMax && matches.length >= askMax) {
Expand Down