Hazelight / vscode-unreal-angelscript

Visual Studio Code Language Server and Debug Adapter for use with UnrealEngine-Angelscript.
MIT License
94 stars 43 forks source link

Feat: add setting for ignoring glob patterns when searching for AS files #37

Closed mikeseese closed 1 year ago

mikeseese commented 1 year ago

This PR adds a setting to ignore an array of glob patterns to prevent picking up duplicate files. For example, when I try to "Go to Definition" sometimes the language server will bring me to Saved/StagedBuilds/.../File.as, .plastic/fileCache/.../File.as (the VSCode extension for PlasticSCM uses this directory to enable file diffs in VSCode), or builds/.../File.as (which is where I put packaged builds). I added Saved and .plastic as defaults as are not specific to me; happy to change as you see fit.

Lucas7211 commented 1 year ago

Sounds like a useful feature, but if I read this correctly it's not just ignoring things in folders named "Saved" by default, but also any files that have "Saved" in the filename. Could you change the pattern so it only ignores folders literally named that?

mikeseese commented 1 year ago

Turns out ignore: ["Saved"] only ignores files in the root directory named Saved exactly (not just part of the name). To ignore wildcard directories, it would need to be ignore: ["**/Saved/**/*"]. It's a glob pattern that is compared against the full file path rather than individual file/folder names like a .gitignore does. I verified this with a test script:

image


here it is with ["**/Saved/**/*"]

const glob = require("glob");

glob("test/**/*.as", { ignore: ["**/Saved/**/*"]}, (err, files) => {
    console.log(files);
});
$ node test.js
[ 'test/1.as', 'test/2Saved.as', 'test/Saved.as' ]

here it is with just ["Saved"]:

$ node test.js
[ 'test/1.as', 'test/2Saved.as', 'test/Saved.as', 'test/Saved/3.as' ]

Though it seems it can be shortened down to ["**/Saved/**"] (also tested this by adding a test/Saved/test/4.as file which was also ignored):

$ node test.js
[ 'test/1.as', 'test/2Saved.as', 'test/Saved.as' ]
Lucas7211 commented 1 year ago

Looks good 👍 Thanks for the pull requests!