-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Search Provider extension API #47058
Comments
export interface TextSearchQuery {
pattern: string;
isRegExp?: boolean;
isCaseSensitive?: boolean;
isWordMatch?: boolean;
}
export interface TextSearchOptions {
folder: Uri;
includes: GlobPattern[];
excludes: GlobPattern[];
maxFileSize?: number;
disregardIgnoreFiles?: boolean;
ignoreSymlinks?: boolean;
encoding?: string;
}
export interface TextSearchResult {
uri: Uri;
range: Range;
preview: { leading: string, matching: string, trailing: string };
}
|
In the |
Yes that's what I'm imagining, and I think includes/excludes maybe should actually just be strings of globs relative to Was the original intention to have the extension read This also doesn't handle searching in extra open files. I'm not sure how to express that.
where just one of those is set. Or maybe they don't need to be differentiated.
|
export interface SearchProvider {
provideFileSearchResults?(options: SearchOptions, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
}
export interface TextSearchQuery {
pattern: string;
isRegExp?: boolean;
isCaseSensitive?: boolean;
isWordMatch?: boolean;
}
export interface SearchOptions {
folder: Uri;
includes: string[]; // paths relative to folder
excludes: string[];
useIgnoreFiles?: boolean;
followSymlinks?: boolean;
previewOptions: TBD; // total length? # of context lines? leading and trailing # of chars?
}
export interface TextSearchOptions extends SearchOptions {
maxFileSize?: number;
encoding?: string;
}
export interface TextSearchResult {
uri: Uri;
range: Range;
// For now, preview must be a single line of text
preview: { text: string, match: Range };
}
|
Need to decide whether the search provider API options include maxResults. When maxResults is hit, the expensive search should terminate as quickly as possible, so it makes sense for the provider to know about it. Especially important in the workspaceContains case where maxResults = 1. But the search service needs to know whether maxResults would have been exceeded, so it can show a warning in the text search viewlet. (What else do we use We could pass maxResult+1 to the provider so we know whether the provider has exactly 10,000 results, or would have produced more. Not good for the maxResults=1 case because some providers may have an optimization for just finding whether a pattern exists. So, we could pass maxResults=1 in that case and maxResults+1 in all other cases. This is assuming |
As someone in the |
From e69e4d3, it appears that it was a recent+deliberate change to no longer make |
That's correct, but this is because provideFileSearchResults is expected to return results in order sorted by relevance, and are only displayed when the full result set has loaded, but text results are always sorted by file path and displayed incrementally. I think that this makes the intent of how these are supposed to use more clear, even though the asymmetry bugs me too. |
re: FileIndexProvider - Did some basic perf testing and realized that URI-ifying every file in the workspace is... very expensive. I've always thought of this as a string-based API. Can we change it to return strings of relative paths? I think it's justifiable even if we usually use URIs to refer to files. We are in a clear context of asking for files in a particular folder. |
No - the API uses |
Then FileIndexProvider is ☠️ 😢 |
Playing around with the insider build, I just noted that the results returned by a In my current project the language internally organizes files into virtual folders, it does this as the language allows files to appear at multiple locations within a virtual tree. I was hoping to implement a custom search that allows filtering by include / exclude, but as VS Code always filters the results based on the uri which does not reflect this structure, I always end up with empty result sets. |
This issue is old and a bit stale, I am closing it and opening more specific issues. |
I looked into what it will take to run search in the extension host using extension APIs.
extension authors to think of that?)
The text was updated successfully, but these errors were encountered: