Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you pass multiple glob strings to vscode findFiles api

Tags:

I would like to ignore folders that have been excluded in the workspace settings when I call the api findFiles (https://code.visualstudio.com/Docs/extensionAPI/vscode-api#WorkspaceConfiguration), however I'm not sure how to do this. I have tried looking for a way to combine glob statements but I haven't had much luck. I've found the GLOB_BRACE examples, but I don't think that will work in this case.

(e.g. glob("{foo/.cpp,bar/.cpp}", GLOB_BRACE))

Is there a way to pass multiple directories to the glob statement in findFiles to ignore?

I ideally would like to do something like this...

let search_config = vscode.workspace.getConfiguration( "search" );
let search_exclude_settings = search_config.get( "exclude" );
let exclude_properties = "{";
for ( var exclude in search_exclude_settings ) {
    if( search_exclude_settings.hasOwnProperty( exclude ) ) {
        exclude_properties += exclude + ",";
    }
}
exclude_properties += filename_and_extension + "}";

var files = vscode.workspace.findFiles(filename_search, exclude_properties, 100);

but unfortunately that doesn't work. Any ideas would be greatly appreciated! I do apologise if I'm probably missing something blindingly obvious.

Thank you for your time!

Tom

like image 896
Tom Avatar asked Jun 27 '16 20:06

Tom


People also ask

How do I add a code to Visual Studio API?

Import an API In Visual Studio Code, select the Azure icon from the Activity Bar. In the Explorer pane, expand the API Management instance you created. Right-click APIs, and select Import from OpenAPI Link.

What is Uri VSCode?

package vscode @:jsRequire("vscode","Uri") A universal resource identifier representing either a file on disk or another resource, like untitled resources.


1 Answers

Okay so it turns out the code example I listed above does actually work and I just hadn't realised it face palm

I had a quick look at the vscode source and in src/vs/base/commom/glob.ts there are some examples of the regex expressions you can use and how they're parsed. Using '{' and then ',' as separators is handled correctly.

like image 153
Tom Avatar answered Nov 15 '22 05:11

Tom