From aed453092b7c94b96360c00e958798eb0bb7b01f Mon Sep 17 00:00:00 2001 From: zhangbk1 Date: Sun, 7 Apr 2024 17:02:17 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=E5=88=86=E9=9A=94=E7=9B=B8=E5=85=B3=E8=BD=AC=E6=8D=A2=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E7=82=B9=E5=87=BB=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 17 +---------------- src/type-definition/SupportCaseType.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 4f72623..328a1d1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode'; import handleEditorReplace from './extension-handler/editor-submenu-handler'; import { handleQuickPick } from './extension-handler/quick-pick-handler'; -import { SupportCase } from './type-definition/SupportCaseType'; +import { SupportCase, commands } from './type-definition/SupportCaseType'; import { createStatusBarItem, updateStatusBarItemVisable } from './extension-handler/status-bar-handler'; // This method is called when your extension is activated @@ -55,21 +55,6 @@ export function activate(context: vscode.ExtensionContext) { console.log('editor is undefined'); } - const commands: Array<{ command: string; targetCase: SupportCase }> = [ - { command: 'variable-conversion.toCamelCase', targetCase: SupportCase.CAMEL_CASE }, - { command: 'variable-conversion.toPascalCase', targetCase: SupportCase.PASCAL_CASE }, - { command: 'variable-conversion.toSnakeCase', targetCase: SupportCase.SNAKE_CASE }, - { command: 'variable-conversion.toSnakeUpperCase', targetCase: SupportCase.SNAKE_UPPER_CASE }, - { command: 'variable-conversion.toSnakePascalCase', targetCase: SupportCase.SNAKE_PASCAL_CASE }, - { command: 'variable-conversion.toSnakeCamelCase', targetCase: SupportCase.SNAKE_CAMEL_CASE }, - { command: 'variable-conversion.toKebabCase', targetCase: SupportCase.KEBAB_CASE }, - { command: 'variable-conversion.toKebabUpperCase', targetCase: SupportCase.KEBAB_UPPER_CASE }, - { command: 'variable-conversion.toKebabPascalCase', targetCase: SupportCase.KEBAB_PASCAL_CASE }, - { command: 'variable-conversion.toKebabCamelCase', targetCase: SupportCase.KEBAB_CAMEL_CASE }, - { command: 'variable-conversion.toLowerCase', targetCase: SupportCase.LOWER_CASE }, - { command: 'variable-conversion.toUpperCase', targetCase: SupportCase.UPPER_CASE }, - ]; - for (const { command, targetCase } of commands) { let disposable = vscode.commands.registerCommand(command, () => { handleEditorReplace(targetCase); diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index 7579e2a..13d2762 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -233,6 +233,32 @@ const keyword = { ], }; +/** + * 接管的字符串转换命令 + */ +export const commands: Array<{ command: string; targetCase: SupportCase }> = [ + { command: 'variable-conversion.toCamelCase', targetCase: SupportCase.CAMEL_CASE }, + { command: 'variable-conversion.toPascalCase', targetCase: SupportCase.PASCAL_CASE }, + + { command: 'variable-conversion.toSnakeCase', targetCase: SupportCase.SNAKE_CASE }, + { command: 'variable-conversion.toSnakeUpperCase', targetCase: SupportCase.SNAKE_UPPER_CASE }, + { command: 'variable-conversion.toSnakePascalCase', targetCase: SupportCase.SNAKE_PASCAL_CASE }, + { command: 'variable-conversion.toSnakeCamelCase', targetCase: SupportCase.SNAKE_CAMEL_CASE }, + + { command: 'variable-conversion.toKebabCase', targetCase: SupportCase.KEBAB_CASE }, + { command: 'variable-conversion.toKebabUpperCase', targetCase: SupportCase.KEBAB_UPPER_CASE }, + { command: 'variable-conversion.toKebabPascalCase', targetCase: SupportCase.KEBAB_PASCAL_CASE }, + { command: 'variable-conversion.toKebabCamelCase', targetCase: SupportCase.KEBAB_CAMEL_CASE }, + + { command: 'variable-conversion.toSpaceCase', targetCase: SupportCase.SPACE_CASE }, + { command: 'variable-conversion.toSpaceUpperCase', targetCase: SupportCase.SPACE_UPPER_CASE }, + { command: 'variable-conversion.toSpacePascalCase', targetCase: SupportCase.SPACE_PASCAL_CASE }, + { command: 'variable-conversion.toSpaceCamelCase', targetCase: SupportCase.SPACE_CAMEL_CASE }, + + { command: 'variable-conversion.toLowerCase', targetCase: SupportCase.LOWER_CASE }, + { command: 'variable-conversion.toUpperCase', targetCase: SupportCase.UPPER_CASE }, +]; + /** * 所有支持的命名方式 * @since 2024-04-06