From 4c51b72892688741faf9b3cb65932c2e71262bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A=E5=87=AF?= Date: Wed, 4 Dec 2024 00:03:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E5=A4=84=20ts=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=E9=97=AE=E9=A2=98=20(funct?= =?UTF-8?q?ion:=20getUserConfigurations)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension-handler/quick-pick-handler.ts | 2 +- src/extension.ts | 2 +- src/main-code/user-configuration.ts | 4 ++-- src/main-code/variable-convert/cyclic-conversion.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/extension-handler/quick-pick-handler.ts b/src/extension-handler/quick-pick-handler.ts index 0c59bf8..edc283f 100644 --- a/src/extension-handler/quick-pick-handler.ts +++ b/src/extension-handler/quick-pick-handler.ts @@ -98,7 +98,7 @@ export function handleQuickPick() { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; // 排除禁用的选项 const enabledQuickPickSupportCases = []; for (const quickPick of quickPickSupportCases) { diff --git a/src/extension.ts b/src/extension.ts index 48eb6f0..95d26e1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -44,7 +44,7 @@ export function activate(context: vscode.ExtensionContext) { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; // 更新右键菜单每一项是否展示 for (const { settingsKey } of commands) { vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); diff --git a/src/main-code/user-configuration.ts b/src/main-code/user-configuration.ts index 3fb93d0..536968f 100644 --- a/src/main-code/user-configuration.ts +++ b/src/main-code/user-configuration.ts @@ -7,10 +7,10 @@ import vscode from 'vscode'; * @returns 配置项的值 * @since 2024-07-29 */ -function getUserConfigurations(configKey: string) { +function getUserConfigurations(configKey: string): T | undefined { const config = vscode.workspace.getConfiguration('variable-conversion'); - const configValue = config.get(configKey); + const configValue = config.get(configKey); console.log('configValue:', configValue); return configValue; } diff --git a/src/main-code/variable-convert/cyclic-conversion.ts b/src/main-code/variable-convert/cyclic-conversion.ts index 90064a9..40027ce 100644 --- a/src/main-code/variable-convert/cyclic-conversion.ts +++ b/src/main-code/variable-convert/cyclic-conversion.ts @@ -66,7 +66,7 @@ function lazyConvert() { } // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; const textList = userSelection.currentSelectionsText; // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));