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

workspace.findFiles with exclude pattern behaves differently than documented #151211

Closed
kryops opened this issue Jun 3, 2022 · 1 comment
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@kryops
Copy link

kryops commented Jun 3, 2022

  • VS Code Version: 1.67.2
  • OS Version: macOS 12.4

The current API documentation for workspace.findFiles() contains the following description for the exclude param:

A glob pattern that defines files and folders to exclude. The glob pattern will be matched against the file paths of resulting matches relative to their workspace. When undefined, default file-excludes (e.g. the files.exclude-setting but not search.exclude) will apply. When null, no excludes will apply.

(via https://code.visualstudio.com/api/references/vscode-api)

However, the files.exclude setting does not only seem to be applied by default (or when using undefined as documented), but also when specifying a string exclude pattern. Only when explicitly specifying null, the setting is not applied.

In my use case I want to find some files that are usually hidden from the developer (thus I don't want files.exclude to be applied), but I want to exclude some large directories like node_modules and .git from the search for better performance:

const files = await vscode.workspace.findFiles('**/.development/_typing.d.ts', '**/{node_modules,.git}');

This won't find my files - it only works after replacing my exclude pattern with null.

Is this a bug? Or is the documentation just not clear for this case?

Relevant code:

Related issues:

Thanks for looking into it!

@roblourens
Copy link
Member

roblourens commented Jun 10, 2022

To me, it's implied that files.exclude is applied by default, then we describe the difference between null/undefined. To me, it would be very confusing to not apply the default excludes when you specify a query, but then to add extra excludes when you pass undefined. In any case, this does lack flexibility for cases like yours, and we do need to revamp this API. I think that's covered by the other issues you found. Sorry that it doesn't currently fit your needs.

@roblourens roblourens added the *duplicate Issue identified as a duplicate of another issue(s) label Jun 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants