-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Experience with provideTextSearchResults #45000
Comments
I was experimenting with this API too and wasn't sure what the plan is, will I be able to replace the built in local search provider for local files? |
@siegebell Thanks for trying this and thanks for the feedback. Things are still rough but I pushed a couple of changes that should ease some pain, esp. cancelation and progress should be working now. Also, note that I have pulled the search-functionality out of the file system provider into a The proposal is now this export interface SearchProvider {
provideFileSearchResults?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
}
export namespace workspace {
export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable;
} and how it is in action, (progress/cancelation ftw) |
Good point and something that needs to be defined better. I went with the leading/matching/trailing model to prevent the long lines but there are parts of our internal search model I don't know well. I think we need two things: (1) the location of the search match and (2) a preview-string and a pointer inside that preview-string highlighting the actual match. For instance something like this export interface TextSearchResult {
location: { uri: Uri, range: Range };
preview?: { text: string, range: Range };
} and then a query would also express if and how much preview is desired, e.g. preview just the line of the match or preview the lines above/below (similar to export interface TextSearchQuery {
preview: number;
// ... more ...
} |
@roblourens Decoupling the preview from the actual location (as described above) needs some refactoring I believe. |
Yes it does, there are issues with searching in long lines like #31551 and we should be doing that differently. |
@jrieken @bolinfest @hansonw
I've implemented
FileSystemProvider.provideTextSearchResults
from the proposed API. Overall it's working very well! For anyone who might play around with this, and to help the API mature, here are my less-nice experiences:token.onCancellationRequested
is never invoked. Same with clicking the "cancel search" button or toggling an option likeisRegExp
.Range
I report back is almost completely ignored. Columns are instead calculated by the length of the leading and trailing strings:https://github.com/Microsoft/vscode/blob/42de6cc82f2dcd7866b0b88bccf0984f9d4d9e90/src/vs/workbench/api/node/extHostFileSystem.ts#L150
TextSearchQuery
definesisRegex
: https://github.com/Microsoft/vscode/blob/42de6cc82f2dcd7866b0b88bccf0984f9d4d9e90/src/vs/vscode.proposed.d.ts#L88 butisRegExp
is given instead: https://github.com/Microsoft/vscode/blob/42de6cc82f2dcd7866b0b88bccf0984f9d4d9e90/src/vs/platform/search/common/search.ts#L93isSmartCase
is also given, butTextSearchQuery
does not define it. (Looks even more experimental since it's not exposed in the UI?)isRegExp
,isCaseSensitive
, andisWordMatch
, perhaps the fields inTextSearchQuery
should not be nullable.RelativePath
and which base directories I should search. For now, my interpretation is this:includes
andexcludes
, but ignore the relative patterns who'sbase
is not a subdirectory of the folder.The text was updated successfully, but these errors were encountered: