-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Contributable SearchProvider #32549
Contributable SearchProvider #32549
Conversation
@bolinfest Trying to pick your brain on this, esp. on how your would a search query like to be. Today, in VS Code queries are using regular expressions, those from JS and preferably those from ripgrep/rust. Is that an option for your index-based search solution or do need something more conservative? |
@jrieken The API proposal looks fine for our scenarios. Here's our feedback regarding the outstanding questions: Search for files:
Search in files:
A couple of questions:
|
Yeah, we track that in #9049. Once we know how queries and results look we can tackle this
Yep, that's the goal |
@jrieken Apologies, just saw this. In general, I would favor giving flexibility to the provider. For example, VS Code should not do the sorting because we are interested in playing with "personalized search" where the files are ranked according to how much you have interacted with them rather than an alphabetical sort, so we wouldn't want VS Code to override the order we provide. For providers like ours where we expect to do the sorting, it doesn't make a difference to us whether we can stream results or not because we have to aggregate all of the results before we do the sort, anyway. I could certainly imagine that this is not the case for all providers, though. In terms of "Ways to express what you are looking for," how would VS Code expose this in its UI? For example, the simplest thing is for us to register two providers: one that interprets the query as a regex and one that interprets it as plaintext. Then it is up to the user to choose the appropriate provider. However, if there were a structured way to express these options and then VS Code presented them to the user (for example, as a checkbox in the regex vs. plaintext example), then this becomes more interesting. I think I'm missing the UI piece in this proposal: what were you envisioning? |
We wanna stick to our 'data provider'-pattern with this, so no UI proposal but the plan is to use the existing UI and merge results from different providers. In return, that means our current UI isn't set in stone and might have to change for new requirements/scenarios. Today, the "find in files"-UI has query-toggles for 'whole word', 'case-sensitive', and 'regex'-search. It also has input fields for include and exclude (glob) patterns. The UI for "find files" is more simple and just the quick pick box as shown below. However, some project excludes also apply, e.g. don't search in node_modules, don't find generated JS files but their TS files etc... Ideally search result providers support those things too and ideally we can treat all results equal and merge them. That also touches on sorting/ranking. Since one provider has a local view of the world it cannot tell how its results should compare against results from other providers. That's why usually we sort and rank things, e.g completion items or reference search results. |
This PR contains an experiment to apply the "provider-pattern" to our search logic (find in and for files). This is part of the larger remote development scenario.
[edited with details and more ideas]
The API should cover two purposed, searching for and in files and IMO there should be two APIs/providers for this. Let's gather some requirements:
Search For Files
Ways to express what you are looking for
*.png
{**/*.test.ts,src/**/*.js}
foa
matchesi Find characters in the Order in which they Appear in the query
foa
only matchesfoa the people
FYI - today the extension API already allows to
findFiles
and it allows to define queries using glob-patterns;Results
I think it's fair to define the result as a stream of
Uri
s. They are easy to create and VS Code handles them well. Questions might beSearch In Files
Ways to express what you are looking for
Unsure if we need to define the exact regex feature set or if this should be more pragmatic and just be a best effort approach where each provider can decide how to interpret a query
Results