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

introduce findFiles2 API #203844

Merged
merged 11 commits into from Feb 7, 2024
Merged

introduce findFiles2 API #203844

merged 11 commits into from Feb 7, 2024

Conversation

andreamah
Copy link
Contributor

@andreamah andreamah commented Jan 30, 2024

The current findFiles API does not allow for the caller to incorporate default excludes (search.excludes and files.excludes) in addition to custom excludes. I currently don't have plans on finalizing this and having this replace findFiles in the near future, but copilot currently needs something like this to improve perf.

You can test it via:

	vscode.commands.registerCommand('extension.testFindFiles2', async (args) => {
		await vscode.workspace.findFiles2('**/deadends*', {
			exclude: '**/*.ts',
			useIgnoreFiles:true,
		}).then(r => r.forEach(item => 
			console.log(item.toString())));
	});

WIP, haven't written tests for this.

EDIT: for now, it seems to be fuzzy-searching. I will need to look into that. Perhaps I need to add an extra arg for fuzzy vs non-fuzzy searching in the internal API...

Fixes #204657

@andreamah andreamah self-assigned this Jan 30, 2024
@jrieken
Copy link
Member

jrieken commented Feb 2, 2024

I like this and if this works well we should also target this for finalization. Looks like a small change that will help many extensions.

In addition to useIgnoreFiles (or instead) we could have something like useConfiguredExcludes, e.g I am looking for a flag that makes the API behave just like file quick pick. So if a user/workspace runs file quick pick over node_modules or so than that's their choice and extension should have a simple/default way to play along

@andreamah
Copy link
Contributor Author

In addition to useIgnoreFiles (or instead) we could have something like useConfiguredExcludes, e.g I am looking for a flag that makes the API behave just like file quick pick. So if a user/workspace runs file quick pick over node_modules or so than that's their choice and extension should have a simple/default way to play along

I think, by default, this API and findTextInFiles can just set useDefaultExcludes:true and it will already follow the excludes that you see in the editor. This is because the *ignoreFiles arguments will already use the configured excludes if not set. Interestingly, although findTextInFiles says that useDefaultExcludes:true is default, it isn't (see this issue #204179). To me, it makes the most sense for both APIs to have useDefaultExcludes:true so that setting none of the useDefaultExcludes/*ignoreFiles settings assumes the normal quickpick behavior.

I'll probably bring this to the API sync because I have questions regarding how best to go about a 'first draft' of this API such that it can eventually be finalized.

@andreamah andreamah marked this pull request as ready for review February 7, 2024 21:38
@VSCodeTriageBot VSCodeTriageBot added this to the February 2024 milestone Feb 7, 2024
@andreamah andreamah merged commit 20d1817 into main Feb 7, 2024
6 checks passed
@andreamah andreamah deleted the joint-cuckoo branch February 7, 2024 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce workspace.FindFiles2 API
4 participants