diff --git a/package.json b/package.json index 13f34cf..1de0b47 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "antd-design-token", "displayName": "antd Design Token", "description": "VSCode extension for antd v5 design token.", - "version": "0.3.1", + "version": "0.3.3", "publisher": "shezhangzhang", "engines": { "vscode": "^1.68.0" diff --git a/src/extension.ts b/src/extension.ts index 3b7270d..4d16de5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,8 +7,7 @@ import setupAntdTokenCompletion from "./typing"; import { checkAntdProject } from "./utils"; export function activate(context: vscode.ExtensionContext) { - const ACTIVE_KEY = "antd-design-token-active-key"; - const isActive = context.globalState.get(ACTIVE_KEY); + let isActive = true; let disposeTyping: vscode.Disposable | undefined; let disposableAndClear: DisposableAndClear | undefined; let disposeEditor: vscode.Disposable | undefined; @@ -20,19 +19,17 @@ export function activate(context: vscode.ExtensionContext) { const disposable = vscode.commands.registerCommand( "antd-design-token.toggle", () => { - const isActive = context.globalState.get(ACTIVE_KEY); - context.globalState.update(ACTIVE_KEY, !isActive); + isActive = !isActive; + disposeAll(); if (isActive) { - disposeAll(); + setup(); vscode.window.showInformationMessage( - "antd design token is inactive now." + "antd design token is active now." ); } else { - disposeEditor?.dispose(); - setup(); vscode.window.showInformationMessage( - "antd design token is active now." + "antd design token is inactive now." ); } } @@ -77,6 +74,10 @@ export function activate(context: vscode.ExtensionContext) { disposableAndClear.clear(); disposableAndClear = undefined; } + + if (disposeEditor) { + disposeEditor.dispose(); + } } function activeEditorListener(fullToken: any) {