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

Test: findFiles2New (new FindFiles API shape) #226670

Closed
3 tasks done
andreamah opened this issue Aug 26, 2024 · 0 comments
Closed
3 tasks done

Test: findFiles2New (new FindFiles API shape) #226670

andreamah opened this issue Aug 26, 2024 · 0 comments

Comments

@andreamah
Copy link
Contributor

andreamah commented Aug 26, 2024

Refs #48674

Complexity: 4
Roles: Developer, Engineering Manager

Create Issue


History/Context

FYI: you can skip this part if you already know what's going on with these search APIs.

General

There has been a lot of work going into finalizing 4 search APIs. Here is a little table that soft of explains how they're related, plus the main function calls from each. Essentially, for file and text search, we have to finalize APIs for

  1. Leveraging whatever providers (ie: ripgrep) that vscode has access to in order to find text and files (finders).
  2. Given that a user is using API or the UI to find text or files, being able to provide results (ie: if someone had a virtual file system, this helps with giving accurate results) (consumers)

Image

findFiles2 is meant to replace the existing finalized API workspace.findFiles. So it will be renamed to findFiles then. It will be added as an overload of the current findFiles call, where the old call signature will be deprecated (but still supported).

Since this is gonna be a huge change for any first-party extensions that are using these proposed APIs, I've split out the new shape in new files that end in New. For example, the new shape for findTextInFiles is in findTextInFilesNew.

findFiles2New

This TPI focuses on testing the functionality and shape for findFiles2New

An extension would use the findFiles2New API when it wants to find text search results in the user's workspace.

Note that a 'file search' is what happens when you do CTRL+P/CMD+P and search for a file in your workspace. You would use findFiles2New if you were an extension that wanted to get a list of file search results that matches a certain pattern.

Set up

Update to the latest Insiders.

Create an extension to test with. To enable the proposed API, use the following in your package.json:

  "enabledApiProposals": [
    "findFiles2New",
    "findFiles2"
  ]

and run npx vscode-dts dev to download the proposed API files.

You're going to test findFiles2New, which is the new shape for findFiles2.

See below for the shape to test:
https://github.com/microsoft/vscode/blob/94f869842859c273491a8067d81f82f5fb30709a/src/vscode-dts/vscode.proposed.findFiles2New.d.ts

Testing

In your extension, call the function vscode.workspace.findFiles2New with the different options available.

For example,

		const include=['**/test/**', '**/*.ts'];
		const exclude= ['**lru**', '**/binaryMap**'];
		const results = await vscode.workspace.findFiles2New(include, {exclude});

Try to be creative with the options you use, and please refer to the documentation in the proposed API file for details on how to use each.

If you're feeling extra gutsy, you can even test with the new fileSearchProviderNew API (but don't feel too pressured to do this- I have another TPI to test this API in-depth)! :)

Thanks for testing! Please message me if you have any questions! I intentionally left this testing section vague so that I can get a measure of how easy it is to adopt the API.

Known Bugs

  • Any element assigned to the exclude option can be a GlobPattern, which, in turn, can be a RelativePattern. This being said, it can have a baseUri, but VS Code's internal file/text search doesn't pay attention to that field. In all cases, it will only read the pattern component of the RelativePattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants
@connor4312 @karthiknadig @alexdima @andreamah and others