From 3b8c6ac6bcf769e668c3e1ee0cd23f33054ca315 Mon Sep 17 00:00:00 2001 From: QiroNT Date: Sun, 19 Jun 2022 21:30:49 +0800 Subject: [PATCH] fix(vscode): fix configExists logic --- packages/vscode/src/contextLoader.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/vscode/src/contextLoader.ts b/packages/vscode/src/contextLoader.ts index dc7510c95b..36d49c327b 100644 --- a/packages/vscode/src/contextLoader.ts +++ b/packages/vscode/src/contextLoader.ts @@ -79,7 +79,7 @@ export class ContextLoader { const files = await readdir(dir) this.configExistsCache.set(dir, files.some(f => /^(vite|svelte|astro|iles|nuxt|unocss|uno)\.config/.test(f))) } - return this.configExistsCache.has(dir)! + return this.configExistsCache.get(dir)! } async loadContextInDirectory(dir: string) { @@ -189,13 +189,12 @@ export class ContextLoader { if (fs.existsSync(file)) { let dir = path.dirname(file) while (isSubdir(this.cwd, dir)) { - if (!await this.configExists(dir)) - continue - - const context = await this.loadContextInDirectory(dir) - if (context?.filter(code, file)) { - this.fileContextCache.set(file, context) - return context + if (await this.configExists(dir)) { + const context = await this.loadContextInDirectory(dir) + if (context?.filter(code, file)) { + this.fileContextCache.set(file, context) + return context + } } const newDir = path.dirname(dir)