From f0a023381e5b4674989ecd676c250bacee92772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Smolarek?= <34063647+Razz4780@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:22:14 +0100 Subject: [PATCH] Update config files search (#105) * Using two patterns to match files * Changelog entry --- changelog.d/+available-config-search.fixed.md | 1 + src/config.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelog.d/+available-config-search.fixed.md diff --git a/changelog.d/+available-config-search.fixed.md b/changelog.d/+available-config-search.fixed.md new file mode 100644 index 00000000..aa314066 --- /dev/null +++ b/changelog.d/+available-config-search.fixed.md @@ -0,0 +1 @@ +Fixed available configs list (displayed when setting active config) to include files located in `*.mirrord` directories. \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 99692661..e4bbaf84 100644 --- a/src/config.ts +++ b/src/config.ts @@ -173,8 +173,14 @@ export class MirrordConfigManager { */ public async selectActiveConfig() { const options: Map = new Map(); - const files = await vscode.workspace.findFiles("**/*mirrord.{json,toml,yml,yaml}"); - files.forEach(f => options.set(vscode.workspace.asRelativePath(f), f)); + + const filePatterns = [ + "**/*mirrord.{json,toml,yml,yaml}", // known extensions, names ending with `mirrord` + "**/*.mirrord/*.{json,toml,yml,yaml}", // known extensions, located in directories with names ending with `.mirrord` + ]; + + const files = await Promise.all(filePatterns.map(pattern => vscode.workspace.findFiles(pattern))); + files.flat().forEach(file => options.set(vscode.workspace.asRelativePath(file), file)); const displayed = this.active ? ["", ...options.keys()] : [...options.keys()]; const placeHolder = this.active