Skip to content

introduce findFiles2 API - #203844

Merged
Andrea Mah (andreamah) merged 11 commits into
mainfrom
joint-cuckoo
Feb 7, 2024
Merged

Andrea Mah (andreamah) merged 11 commits into
mainfrom
joint-cuckoo

Conversation

@andreamah

@andreamah Andrea Mah (andreamah) commented Jan 30, 2024 •

Copy link
Copy Markdown
Contributor

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

@jrieken

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Andrea Mah (andreamah) marked this pull request as ready for review February 7, 2024 21:38
@vscodenpa VS Code Bot (vscodenpa) added this to the February 2024 milestone Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce workspace.FindFiles2 API

4 participants