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

findFiles ignores 'base' part of exclude glob #52651

Open
roblourens opened this issue Jun 22, 2018 · 5 comments
Open

findFiles ignores 'base' part of exclude glob #52651

roblourens opened this issue Jun 22, 2018 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member search Search widget and operation issues
Milestone

Comments

@roblourens
Copy link
Member

This searches for *.ts files and excludes .ts files in the second workspace folder.

vscode.workspace.findFiles('**/*.ts', new vscode.RelativePattern(vscode.workspace.workspaceFolders[1], '**/*.ts')).then(result => {
        console.log(result);
});

When I run this, I get 0 results, when it should return results from the first workspace folder.

Seems like it's always been that way. Is that intentional @bpasero? If not I can fix it. We can pass absolute exclude globs to search.

https://github.com/Microsoft/vscode/blob/b7e6e04666ca8dde560b69081c43365dce77d12a/src/vs/workbench/api/node/extHostWorkspace.ts#L357

@roblourens roblourens self-assigned this Jun 22, 2018
@bpasero
Copy link
Member

bpasero commented Jun 25, 2018

@roblourens that looks like a bug to me, I would also expect to find any *.ts file from the first workspace folder.

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug search Search widget and operation issues labels Jun 25, 2018
@roblourens roblourens modified the milestones: June 2018, July 2018 Jun 25, 2018
@roblourens roblourens modified the milestones: August 2018, On Deck Aug 29, 2018
@ArtyMaury
Copy link

On the same idea, I'm trying to give users the possibility to include folders in a file search, in a multi or single root workspace.
It looks like:

let globPatternSource = `**/*.yml`;
if (sourceFolders !== undefined && sourceFolders.length > 0) {
    globPatternSource = `{${sourceFolders.join(",")}}/**/*.yml`;
}
vscode.workspace.findFiles(globPatternSource);

On a single root workspace it works fine, but with multi-root they can't just include "rootA", they would have to include all of rootA subfolders because the roots are already included in the search path.

Is that the same issue or is that intentional?

@roblourens
Copy link
Member Author

but with multi-root they can't just include "rootA", they would have to include all of rootA subfolders because the roots are already included in the search path.

Sorry I don't understand what you're trying to do. You want to search a root, but not search its subfolders?

@ArtyMaury
Copy link

ArtyMaury commented Oct 15, 2018

Sorry I wasn't clear.
Imagine a multi-root workspace like:

RootA:

  • fileA.yml

RootB:

  • fileB.yml

I'd like findFiles("RootA/**/*.yml") to return fileA.yml. But at the moment it doesn't return anything because the resolved search queries are "RootA/RootA/**/*.yml" and "RootB/RootA/**/*.yml".

To me, the root folders shouldn't be included in the query.

Was I clearer?

@roblourens
Copy link
Member Author

I see - this is what RelativePattern is for - https://github.com/Microsoft/vscode/blob/master/src/vs/vscode.d.ts#L1805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

4 participants