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

plugin: findFiles should handle ignored files #8452

Merged
merged 1 commit into from
Sep 14, 2020
Merged

Conversation

vince-fugnitto
Copy link
Member

What it does

Fixes: #8451

The following commit updates the findFiles plugin API to respect exclude: null which indicates that the search should yield results in all files (no exclude or ignored constraints).

Before:

image

Pull-Request:

image

How to test

  1. use the vscode extension: vscode-find-files
    (the extension searches for all readme files and prints those within node_modules (gitignored))
  2. start the application
  3. execute the command echo files
  4. there should be results in node_modules

Review checklist

Reminder for reviewers

Signed-off-by: vince-fugnitto vincent.fugnitto@ericsson.com

@vince-fugnitto vince-fugnitto added the vscode issues related to VSCode compatibility label Sep 1, 2020
@vince-fugnitto vince-fugnitto self-assigned this Sep 1, 2020
@vince-fugnitto vince-fugnitto force-pushed the vf/gh-8451 branch 2 times, most recently from f1f0bd6 to fda1279 Compare September 1, 2020 15:30
The following commit updates the `findFiles` plugin API to respect
`exclude: null` which indicates that the search should yield results in
all files (no exclude or ignored constraints).

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
@sapirpol
Copy link

sapirpol commented Sep 3, 2020

Hi @vince-fugnitto,

Why not just to change useGitIgnore param to false?

@vince-fugnitto
Copy link
Member Author

Why not just to change useGitIgnore param to false?

@sapirpol since searching in ignored files should not always be turned on, it should only be turned on if exclude = null based on the documentation:

/**
* Find files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
*
* @sample `findFiles('**​/*.js', '**​/node_modules/**', 10)`
* @param include A [glob pattern](#GlobPattern) that defines the files to search for. The glob pattern
* will be matched against the file paths of resulting matches relative to their workspace. Use a [relative pattern](#RelativePattern)
* to restrict the search results to a [workspace folder](#WorkspaceFolder).
* @param exclude  A [glob pattern](#GlobPattern) 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` only default excludes will
* apply, when `null` no excludes will apply.
* @param maxResults An upper-bound for the result.
* @param token A token that can be used to signal cancellation to the underlying search engine.
* @return A thenable that resolves to an array of resource identifiers. Will return no results if no
* [workspace folders](#workspace.workspaceFolders) are opened.
*/
export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;

For exclude it states (note that vscode uses files.exclude to control the default excludes):

When `undefined` only default excludes will apply, when `null` no excludes will apply.

Here are two examples:

vscode.workspace.findFiles('**/README.md', undefined, 50)... // search for files respecting the default exclude
vscode.workspace.findFiles('**/README.md', null, 50)... // search for files in all files (exclude is `null`)

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the extension worked.

@vince-fugnitto
Copy link
Member Author

I'll merge tomorrow if there are no objections :)

@vince-fugnitto vince-fugnitto merged commit 3ff86e3 into master Sep 14, 2020
@vince-fugnitto vince-fugnitto deleted the vf/gh-8451 branch September 14, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugin: 'findFiles' should search ignored files when exclude is 'null'
3 participants