From 889c9569a4eeac694e8eef6d4b0683836381eeee Mon Sep 17 00:00:00 2001 From: Simon He <57086651+Simon-He95@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:59:10 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=BF=87=E6=BB=A4=E6=8E=89=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8ee43d59..c0a20dff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,9 +7,8 @@ let UINames: any = [] let optionsComponents: any = null let UiCompletions: any = null let cacheMap: any = {} - export function activate(context: vscode.ExtensionContext) { - const filter = ['javascript', 'javascriptreact', 'typescriptreact', 'html', 'vue', 'css'] + const filter = ['javascript', 'javascriptreact', 'typescriptreact', 'vue', 'svelte'] context.subscriptions.push(addEventListener('activeText-change', (editor: vscode.TextEditor) => { // 找到当前活动的编辑器 const visibleEditors = vscode.window.visibleTextEditors @@ -43,8 +42,15 @@ export function deactivate() { cacheMap = null } +const filters = ['js', 'ts', 'jsx', 'tsx', 'vue', 'svelte'] + function findUI() { const cwd = vscode.window.activeTextEditor?.document.uri.fsPath + const suffix = cwd?.split('.').slice(-1)[0] + + if (!suffix || !filters.includes(suffix)) + return + const values = Object.values(cacheMap) as any if (values[0] && values[0].includes(cwd)) return