From f8fe40c37487f60a00ade659166be2054063ef50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sun, 28 Jul 2024 23:47:20 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20VSCode=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=20(=E9=80=BB=E8=BE=91=E5=BE=85=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-comment.jsonc | 108 ++++++++++++++++++++++++- package.json | 79 +++++++++++++++++- src/type-definition/SupportCaseType.ts | 2 +- 3 files changed, 184 insertions(+), 5 deletions(-) diff --git a/package-comment.jsonc b/package-comment.jsonc index bd6ece6..421dc06 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -348,7 +348,113 @@ "id": "variable-conversion.stringConversionMenu", "label": "将变量转换为..." } - ] + ], + // docs: https://code.visualstudio.com/api/references/contribution-points#contributes.configuration + "configuration": { + "title": "Variable Conversion 变量转换", + "properties": { + // 仅测试用 + // "variable-conversion.test1": { + // "title": "定义转换格式的排序", + // "description": "Defines the ordering of the conversion format.\n定义转换格式的排序", + // "type": "array", + // "default": [ + // "camelCase", + // "snake_case", + // "PascalCase" + // ] + // }, + // "variable-conversion.enableFormat": { + // "type": "object", + // "default": { + // "camelCase": true, + // "snake_case": true, + // "PascalCase": true + // }, + // "description": "Define which formats are enabled.\n定义哪些格式是开启的" + // }, + // + // 全小写命名 + // lower_case(全小写), snake_case(下划线), kebab_case(连字符), space_case(空格), dot_case(点) + // 全大写命名 + // upper_case(全大写), snake_upper_case(下划线), kebab_upper_case(连字符), space_upper_case(空格), dot_upper_case(点) + // 大驼峰命名 + // pascal_case(大驼峰), snake_pascal_case(下划线), kebab_pascal_case(连字符), space_pascal_case(空格), dot_pascal_case(点) + // 小驼峰命名 + // camel_case(小驼峰), snake_camel_case(下划线), kebab_camel_case(连字符), space_camel_case(空格), dot_camel_case(点) + "variable-conversion.disableFormat": { + "order": 1, + "type": "array", + "items": { + "type": "string", + "enum": [ + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" + ] + }, + "default": [], + // markdownDescription 最多配置 11 行 + "markdownDescription": "Define which formats are disabled.\n\n定义哪些格式是禁用的\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\n[Restart Extension Host (重启扩展宿主)](command:workbench.action.restartExtensionHost), [Reload Window (重启当前窗口)](command:workbench.action.reloadWindow)" + }, + "variable-conversion.circularConversionFormatOrder": { + "order": 2, + "title": "定义循环转换快捷键的目标格式排序", + // "description": "Defines the destination format ordering of the circular conversion shortcut.\n定义循环转换快捷键的目标格式排序", + // markdownDescription 最多配置 11 行 + "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", + "type": "string", + "items": { + "type": "string", + "enum": [ + "Option1", + "Option2", + "Option3" + ] + }, + "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + } + } + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/package.json b/package.json index 9859852..8348130 100644 --- a/package.json +++ b/package.json @@ -228,11 +228,11 @@ }, { "command": "variable-conversion.toLowerCase", - "group": "group-5-upper-lower@1" + "group": "group-6-upper-lower@1" }, { "command": "variable-conversion.toUpperCase", - "group": "group-5-upper-lower@2" + "group": "group-6-upper-lower@2" } ] }, @@ -241,7 +241,80 @@ "id": "variable-conversion.stringConversionMenu", "label": "将变量转换为..." } - ] + ], + "configuration": { + "title": "Variable Conversion 变量转换", + "properties": { + "variable-conversion.disableFormat": { + "order": 1, + "type": "array", + "items": { + "type": "string", + "enum": [ + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" + ] + }, + "default": [], + "markdownDescription": "Define which formats are disabled.\n\n定义哪些格式是禁用的\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\n[Restart Extension Host (重启扩展宿主)](command:workbench.action.restartExtensionHost), [Reload Window (重启当前窗口)](command:workbench.action.reloadWindow)" + }, + "variable-conversion.circularConversionFormatOrder": { + "order": 2, + "title": "定义循环转换快捷键的目标格式排序", + "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", + "type": "string", + "items": { + "type": "string", + "enum": [ + "Option1", + "Option2", + "Option3" + ] + }, + "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + } + } + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index e4b2418..a4b9a0b 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -3,7 +3,7 @@ * * Code: * - Add type definition in below `SupportCase` enum and following array - * - Add `commands`, `menus` parts in [package.json] and [package-comment.jsonc] + * - Add `commands`, `menus`, `configuration` parts in [package.json] and [package-comment.jsonc] * - Add main conversion logic in [src/main-code/conversion.ts] * * Test: From 68ffcc49f72f524d0e56a94f5671f79a695880e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 22:32:06 +0800 Subject: [PATCH 2/9] =?UTF-8?q?QuickPick=20=E8=8F=9C=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=BF=87=E6=BB=A4=E7=94=A8=E6=88=B7=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E7=A6=81=E7=94=A8=E6=A0=BC=E5=BC=8F=20(disableFormat)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-comment.jsonc | 75 +++++++++++++++++++-- package.json | 72 ++++++++++++++++++-- src/extension-handler/quick-pick-handler.ts | 27 ++++++-- src/main-code/user-configuration.ts | 14 ++++ src/type-definition/SupportCaseType.ts | 30 ++++++++- 5 files changed, 200 insertions(+), 18 deletions(-) create mode 100644 src/main-code/user-configuration.ts diff --git a/package-comment.jsonc b/package-comment.jsonc index 421dc06..bb8b9b5 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -441,17 +441,80 @@ "title": "定义循环转换快捷键的目标格式排序", // "description": "Defines the destination format ordering of the circular conversion shortcut.\n定义循环转换快捷键的目标格式排序", // markdownDescription 最多配置 11 行 - "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", - "type": "string", + // "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", + "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 🐳Default value 默认值: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", + // "type": "string", + // "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + "type": "array", "items": { "type": "string", "enum": [ - "Option1", - "Option2", - "Option3" + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" ] }, - "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + "default": [ + "camel_case", + "snake_case", + "pascal_case", + "kebab_case", + "space_case", + "dot_case", + "snake_upper_case", + "kebab_upper_case", + "space_upper_case", + "dot_upper_case", + "snake_pascal_case", + "kebab_pascal_case", + "space_pascal_case", + "dot_pascal_case", + "snake_camel_case", + "kebab_camel_case", + "space_camel_case", + "dot_camel_case", + "lower_case", + "upper_case" + ] } } } diff --git a/package.json b/package.json index 8348130..8b0aa8d 100644 --- a/package.json +++ b/package.json @@ -301,17 +301,77 @@ "variable-conversion.circularConversionFormatOrder": { "order": 2, "title": "定义循环转换快捷键的目标格式排序", - "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", - "type": "string", + "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 🐳Default value 默认值: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", + "type": "array", "items": { "type": "string", "enum": [ - "Option1", - "Option2", - "Option3" + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" ] }, - "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + "default": [ + "camel_case", + "snake_case", + "pascal_case", + "kebab_case", + "space_case", + "dot_case", + "snake_upper_case", + "kebab_upper_case", + "space_upper_case", + "dot_upper_case", + "snake_pascal_case", + "kebab_pascal_case", + "space_pascal_case", + "dot_pascal_case", + "snake_camel_case", + "kebab_camel_case", + "space_camel_case", + "dot_camel_case", + "lower_case", + "upper_case" + ] } } } diff --git a/src/extension-handler/quick-pick-handler.ts b/src/extension-handler/quick-pick-handler.ts index 5ef9c59..295cc2a 100644 --- a/src/extension-handler/quick-pick-handler.ts +++ b/src/extension-handler/quick-pick-handler.ts @@ -1,11 +1,12 @@ import * as vscode from 'vscode'; import QuickPickItemEx from "../type-definition/QuickPickItemExType"; -import { quickPickSupportCases } from '../type-definition/SupportCaseType'; +import { QuickPickSupportCaseItem, quickPickSupportCases } from '../type-definition/SupportCaseType'; import { TransformTextResult } from '../type-definition/TransformTextResultType'; -import { transformMutliLineText, transformMutliSelectionText } from '../main-code/transform'; +import { transformMutliSelectionText } from '../main-code/transform'; import { EOL } from '../type-definition/EOLType'; import { caseConversion } from '../main-code/conversion'; import { isStringArrayEqual } from '../main-code/utils'; +import { getUserConfigurations } from '../main-code/user-configuration'; const QuickPickLabelMaxLength = 60; @@ -18,12 +19,12 @@ interface RecommendItem { /** * 弹出的提示 */ -function generateOptionsBasedOnText(textList: string[], eol: EOL): Array { +function generateOptionsBasedOnText(textList: string[], eol: EOL, enabledQuickPickSupportCases: Array): Array { // Cut text 切割文本 const resultsList: Array = transformMutliSelectionText(textList); const mergeResultList: Array = []; - for (const quickPick of quickPickSupportCases) { + for (const quickPick of enabledQuickPickSupportCases) { const conversionResults: Array = []; for (let i = 0; i < textList.length; i++) { const text = textList[i]; @@ -95,8 +96,24 @@ export function handleQuickPick() { return; } + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + // 排除禁用的选项 + const enabledQuickPickSupportCases = []; + for (const quickPick of quickPickSupportCases) { + if (disableFormatList.includes(quickPick.settingsKey)) { + continue; + } + enabledQuickPickSupportCases.push(quickPick); + } + if (enabledQuickPickSupportCases.length === 0) { + vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.disableFormat` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.disableFormat` configuration and try again.'); + return; + } + // 基于选中的文本生成选项 - const options = generateOptionsBasedOnText(textList, eol); + const options = generateOptionsBasedOnText(textList, eol, enabledQuickPickSupportCases); if (options.length === 0) { vscode.window.showInformationMessage('所选内容暂无可选转换,请尝试重新选择\nNo conversion candidates are available for the selected content, please try to select another text.'); return; diff --git a/src/main-code/user-configuration.ts b/src/main-code/user-configuration.ts new file mode 100644 index 0000000..4a9d106 --- /dev/null +++ b/src/main-code/user-configuration.ts @@ -0,0 +1,14 @@ +const vscode = require('vscode'); + +function getUserConfigurations(configKey: string) { + const config = vscode.workspace.getConfiguration('variable-conversion'); + + // 获取 disableFormat 配置项 + const configValue = config.get(configKey); + console.log('configValue:', configValue); + return configValue; +} + +export { + getUserConfigurations +}; diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index a4b9a0b..65bc12c 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -309,130 +309,158 @@ export const commands: Array<{ command: string; targetCase: SupportCase }> = [ { command: 'variable-conversion.toUpperCase', targetCase: SupportCase.UPPER_CASE }, ]; +export interface QuickPickSupportCaseItem { + type: SupportCase, + name: string, + shortName: string, + keyword: string[], + settingsKey: string, +} + /** * 所有支持的命名方式 * @since 2024-04-06 */ -export const quickPickSupportCases = [ +export const quickPickSupportCases: Array = [ { type: SupportCase.CAMEL_CASE, name: '小驼峰(驼峰)命名', shortName: '小驼峰', keyword: keyword.camel, + settingsKey: 'camel_case', }, { type: SupportCase.PASCAL_CASE, name: '大驼峰(帕斯卡)命名', shortName: '帕斯卡', keyword: keyword.pascal, + settingsKey: 'pascal_case', }, { type: SupportCase.SNAKE_CASE, name: '下划线(蛇形)命名', shortName: '蛇形', keyword: [...keyword.snake, ...keyword.lower], + settingsKey: 'snake_case', }, { type: SupportCase.SNAKE_CAMEL_CASE, name: '下划线(蛇形) + 小驼峰(驼峰)命名', shortName: '蛇形驼峰', keyword: [...keyword.snake, ...keyword.camel], + settingsKey: 'snake_camel_case', }, { type: SupportCase.SNAKE_PASCAL_CASE, name: '下划线(蛇形) + 大驼峰(帕斯卡)命名', shortName: '蛇形帕斯卡', keyword: [...keyword.snake, ...keyword.pascal], + settingsKey: 'snake_pascal_case', }, { type: SupportCase.SNAKE_UPPER_CASE, name: '下划线(蛇形) + 全大写命名', shortName: '蛇形大写', keyword: [...keyword.snake, ...keyword.upper], + settingsKey: 'snake_upper_case', }, { type: SupportCase.KEBAB_CASE, name: '中划线(连字符/脊柱式)命名', shortName: '脊柱', keyword: [...keyword.kebab, ...keyword.lower], + settingsKey: 'kebab_case', }, { type: SupportCase.KEBAB_CAMEL_CASE, name: '中划线(连字符/脊柱式) + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.kebab, ...keyword.camel], + settingsKey: 'kebab_camel_case', }, { type: SupportCase.KEBAB_PASCAL_CASE, name: '中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.kebab, ...keyword.pascal], + settingsKey: 'kebab_pascal_case', }, { type: SupportCase.KEBAB_UPPER_CASE, name: '中划线(连字符/脊柱式) + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.kebab, ...keyword.upper], + settingsKey: 'kebab_upper_case', }, { type: SupportCase.SPACE_CASE, name: '空格分隔命名', shortName: '脊柱', keyword: [...keyword.space, ...keyword.lower], + settingsKey: 'space_case', }, { type: SupportCase.SPACE_CAMEL_CASE, name: '空格分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.space, ...keyword.camel], + settingsKey: 'space_camel_case', }, { type: SupportCase.SPACE_PASCAL_CASE, name: '空格分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.space, ...keyword.pascal], + settingsKey: 'space_pascal_case', }, { type: SupportCase.SPACE_UPPER_CASE, name: '空格分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.space, ...keyword.upper], + settingsKey: 'space_upper_case', }, { type: SupportCase.DOT_CASE, name: '点分隔命名', shortName: '脊柱', keyword: [...keyword.dot, ...keyword.lower], + settingsKey: 'dot_case', }, { type: SupportCase.DOT_CAMEL_CASE, name: '点分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.dot, ...keyword.camel], + settingsKey: 'dot_camel_case', }, { type: SupportCase.DOT_PASCAL_CASE, name: '点分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.dot, ...keyword.pascal], + settingsKey: 'dot_pascal_case', }, { type: SupportCase.DOT_UPPER_CASE, name: '点分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.dot, ...keyword.upper], + settingsKey: 'dot_upper_case', }, { type: SupportCase.LOWER_CASE, name: '全小写', shortName: '小写', keyword: keyword.lower, + settingsKey: 'lower_case', }, { type: SupportCase.UPPER_CASE, name: '全大写', shortName: '大写', keyword: keyword.upper, + settingsKey: 'upper_case', }, ]; From 4c302ddbb2eed7cf6ade912bea2d7d8be0c96ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 22:54:19 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=BF=87=E6=BB=A4=E7=94=A8=E6=88=B7=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E7=A6=81=E7=94=A8=E6=A0=BC=E5=BC=8F=20(disab?= =?UTF-8?q?leFormat)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-comment.jsonc | 20 ++++ package.json | 20 ++++ src/extension.ts | 9 ++ src/type-definition/SupportCaseType.ts | 132 ++++++++++++++++++++----- 4 files changed, 155 insertions(+), 26 deletions(-) diff --git a/package-comment.jsonc b/package-comment.jsonc index bb8b9b5..f8d9de9 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -225,87 +225,107 @@ "variable-conversion.stringConversionMenu": [ // group-1-camel { + "when": "!_isHideSubMenuItem_camel_case", "command": "variable-conversion.toCamelCase", "group": "group-1-camel@1" }, { + "when": "!_isHideSubMenuItem_pascal_case", "command": "variable-conversion.toPascalCase", "group": "group-1-camel@2" }, // group-2-snake { + "when": "!_isHideSubMenuItem_snake_case", "command": "variable-conversion.toSnakeCase", "group": "group-2-snake@1" }, { + "when": "!_isHideSubMenuItem_snake_upper_case", "command": "variable-conversion.toSnakeUpperCase", "group": "group-2-snake@2" }, { + "when": "!_isHideSubMenuItem_snake_pascal_case", "command": "variable-conversion.toSnakePascalCase", "group": "group-2-snake@3" }, { + "when": "!_isHideSubMenuItem_snake_camel_case", "command": "variable-conversion.toSnakeCamelCase", "group": "group-2-snake@4" }, // group-3-kebab { + "when": "!_isHideSubMenuItem_kebab_case", "command": "variable-conversion.toKebabCase", "group": "group-3-kebab@1" }, { + "when": "!_isHideSubMenuItem_kebab_upper_case", "command": "variable-conversion.toKebabUpperCase", "group": "group-3-kebab@2" }, { + "when": "!_isHideSubMenuItem_kebab_pascal_case", "command": "variable-conversion.toKebabPascalCase", "group": "group-3-kebab@3" }, { + "when": "!_isHideSubMenuItem_kebab_camel_case", "command": "variable-conversion.toKebabCamelCase", "group": "group-3-kebab@4" }, // group-4-space { + "when": "!_isHideSubMenuItem_space_case", "command": "variable-conversion.toSpaceCase", "group": "group-4-space@1" }, { + "when": "!_isHideSubMenuItem_space_upper_case", "command": "variable-conversion.toSpaceUpperCase", "group": "group-4-space@2" }, { + "when": "!_isHideSubMenuItem_space_pascal_case", "command": "variable-conversion.toSpacePascalCase", "group": "group-4-space@3" }, { + "when": "!_isHideSubMenuItem_space_camel_case", "command": "variable-conversion.toSpaceCamelCase", "group": "group-4-space@4" }, // group-5-dot { + "when": "!_isHideSubMenuItem_dot_case", "command": "variable-conversion.toDotCase", "group": "group-5-dot@1" }, { + "when": "!_isHideSubMenuItem_dot_upper_case", "command": "variable-conversion.toDotUpperCase", "group": "group-5-dot@2" }, { + "when": "!_isHideSubMenuItem_dot_pascal_case", "command": "variable-conversion.toDotPascalCase", "group": "group-5-dot@3" }, { + "when": "!_isHideSubMenuItem_dot_camel_case", "command": "variable-conversion.toDotCamelCase", "group": "group-5-dot@4" }, // group-6-upper-lower { + "when": "!_isHideSubMenuItem_lower_case", "command": "variable-conversion.toLowerCase", "group": "group-6-upper-lower@1" }, { + "when": "!_isHideSubMenuItem_upper_case", "command": "variable-conversion.toUpperCase", "group": "group-6-upper-lower@2" } diff --git a/package.json b/package.json index 8b0aa8d..c08753e 100644 --- a/package.json +++ b/package.json @@ -155,82 +155,102 @@ ], "variable-conversion.stringConversionMenu": [ { + "when": "!_isHideSubMenuItem_camel_case", "command": "variable-conversion.toCamelCase", "group": "group-1-camel@1" }, { + "when": "!_isHideSubMenuItem_pascal_case", "command": "variable-conversion.toPascalCase", "group": "group-1-camel@2" }, { + "when": "!_isHideSubMenuItem_snake_case", "command": "variable-conversion.toSnakeCase", "group": "group-2-snake@1" }, { + "when": "!_isHideSubMenuItem_snake_upper_case", "command": "variable-conversion.toSnakeUpperCase", "group": "group-2-snake@2" }, { + "when": "!_isHideSubMenuItem_snake_pascal_case", "command": "variable-conversion.toSnakePascalCase", "group": "group-2-snake@3" }, { + "when": "!_isHideSubMenuItem_snake_camel_case", "command": "variable-conversion.toSnakeCamelCase", "group": "group-2-snake@4" }, { + "when": "!_isHideSubMenuItem_kebab_case", "command": "variable-conversion.toKebabCase", "group": "group-3-kebab@1" }, { + "when": "!_isHideSubMenuItem_kebab_upper_case", "command": "variable-conversion.toKebabUpperCase", "group": "group-3-kebab@2" }, { + "when": "!_isHideSubMenuItem_kebab_pascal_case", "command": "variable-conversion.toKebabPascalCase", "group": "group-3-kebab@3" }, { + "when": "!_isHideSubMenuItem_kebab_camel_case", "command": "variable-conversion.toKebabCamelCase", "group": "group-3-kebab@4" }, { + "when": "!_isHideSubMenuItem_space_case", "command": "variable-conversion.toSpaceCase", "group": "group-4-space@1" }, { + "when": "!_isHideSubMenuItem_space_upper_case", "command": "variable-conversion.toSpaceUpperCase", "group": "group-4-space@2" }, { + "when": "!_isHideSubMenuItem_space_pascal_case", "command": "variable-conversion.toSpacePascalCase", "group": "group-4-space@3" }, { + "when": "!_isHideSubMenuItem_space_camel_case", "command": "variable-conversion.toSpaceCamelCase", "group": "group-4-space@4" }, { + "when": "!_isHideSubMenuItem_dot_case", "command": "variable-conversion.toDotCase", "group": "group-5-dot@1" }, { + "when": "!_isHideSubMenuItem_dot_upper_case", "command": "variable-conversion.toDotUpperCase", "group": "group-5-dot@2" }, { + "when": "!_isHideSubMenuItem_dot_pascal_case", "command": "variable-conversion.toDotPascalCase", "group": "group-5-dot@3" }, { + "when": "!_isHideSubMenuItem_dot_camel_case", "command": "variable-conversion.toDotCamelCase", "group": "group-5-dot@4" }, { + "when": "!_isHideSubMenuItem_lower_case", "command": "variable-conversion.toLowerCase", "group": "group-6-upper-lower@1" }, { + "when": "!_isHideSubMenuItem_upper_case", "command": "variable-conversion.toUpperCase", "group": "group-6-upper-lower@2" } diff --git a/src/extension.ts b/src/extension.ts index f99605c..5e6464f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,6 +7,7 @@ import { commands } from './type-definition/SupportCaseType'; import { createStatusBarItem, updateStatusBarItemVisable } from './extension-handler/status-bar-handler'; import * as CyclicConversion from './main-code/cyclic-conversion'; import { EOL } from './type-definition/EOLType'; +import { getUserConfigurations } from './main-code/user-configuration'; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -41,6 +42,14 @@ export function activate(context: vscode.ExtensionContext) { // 更新 _textSelectionLength (用于判断是否展示右键菜单) vscode.commands.executeCommand('setContext', '_textSelectionLength', selectTextLength); + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + // 更新右键菜单每一项是否展示 + for (const { settingsKey } of commands) { + vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); + } + // 判断是否展示状态栏按钮 updateStatusBarItemVisable(selectTextLength); diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index 65bc12c..a6f0706 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -281,32 +281,112 @@ 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.toDotCase', targetCase: SupportCase.DOT_CASE }, - { command: 'variable-conversion.toDotUpperCase', targetCase: SupportCase.DOT_UPPER_CASE }, - { command: 'variable-conversion.toDotPascalCase', targetCase: SupportCase.DOT_PASCAL_CASE }, - { command: 'variable-conversion.toDotCamelCase', targetCase: SupportCase.DOT_CAMEL_CASE }, - - { command: 'variable-conversion.toLowerCase', targetCase: SupportCase.LOWER_CASE }, - { command: 'variable-conversion.toUpperCase', targetCase: SupportCase.UPPER_CASE }, +export const commands: Array<{ command: string; targetCase: SupportCase; settingsKey: string }> = [ + { + command: 'variable-conversion.toCamelCase', + targetCase: SupportCase.CAMEL_CASE, + settingsKey: 'camel_case' + }, + { + command: 'variable-conversion.toPascalCase', + targetCase: SupportCase.PASCAL_CASE, + settingsKey: 'pascal_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toSnakeCase', + targetCase: SupportCase.SNAKE_CASE, + settingsKey: 'snake_case' + }, + { + command: 'variable-conversion.toSnakeUpperCase', + targetCase: SupportCase.SNAKE_UPPER_CASE, + settingsKey: 'snake_upper_case' + }, + { + command: 'variable-conversion.toSnakePascalCase', + targetCase: SupportCase.SNAKE_PASCAL_CASE, + settingsKey: 'snake_pascal_case' + }, + { + command: 'variable-conversion.toSnakeCamelCase', + targetCase: SupportCase.SNAKE_CAMEL_CASE, + settingsKey: 'snake_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toKebabCase', + targetCase: SupportCase.KEBAB_CASE, + settingsKey: 'kebab_case' + }, + { + command: 'variable-conversion.toKebabUpperCase', + targetCase: SupportCase.KEBAB_UPPER_CASE, + settingsKey: 'kebab_upper_case' + }, + { + command: 'variable-conversion.toKebabPascalCase', + targetCase: SupportCase.KEBAB_PASCAL_CASE, + settingsKey: 'kebab_pascal_case' + }, + { + command: 'variable-conversion.toKebabCamelCase', + targetCase: SupportCase.KEBAB_CAMEL_CASE, + settingsKey: 'kebab_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toSpaceCase', + targetCase: SupportCase.SPACE_CASE, + settingsKey: 'space_case' + }, + { + command: 'variable-conversion.toSpaceUpperCase', + targetCase: SupportCase.SPACE_UPPER_CASE, + settingsKey: 'space_upper_case' + }, + { + command: 'variable-conversion.toSpacePascalCase', + targetCase: SupportCase.SPACE_PASCAL_CASE, + settingsKey: 'space_pascal_case' + }, + { + command: 'variable-conversion.toSpaceCamelCase', + targetCase: SupportCase.SPACE_CAMEL_CASE, + settingsKey: 'space_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toDotCase', + targetCase: SupportCase.DOT_CASE, + settingsKey: 'dot_case' + }, + { + command: 'variable-conversion.toDotUpperCase', + targetCase: SupportCase.DOT_UPPER_CASE, + settingsKey: 'dot_upper_case' + }, + { + command: 'variable-conversion.toDotPascalCase', + targetCase: SupportCase.DOT_PASCAL_CASE, + settingsKey: 'dot_pascal_case' + }, + { + command: 'variable-conversion.toDotCamelCase', + targetCase: SupportCase.DOT_CAMEL_CASE, + settingsKey: 'dot_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toLowerCase', + targetCase: SupportCase.LOWER_CASE, + settingsKey: 'lower_case' + }, + { + command: 'variable-conversion.toUpperCase', + targetCase: SupportCase.UPPER_CASE, + settingsKey: 'upper_case' + }, ]; export interface QuickPickSupportCaseItem { From 1af0d743dba5be83df257fbf9808a63b4aeca4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 23:01:39 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E8=BD=AC=E6=8D=A2=E6=94=AF=E6=8C=81=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=85=8D=E7=BD=AE=E7=9A=84=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=20(disableFormat)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main-code/cyclic-conversion.ts | 12 ++++++- src/type-definition/SupportCaseType.ts | 47 ++++++++++++++------------ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/main-code/cyclic-conversion.ts b/src/main-code/cyclic-conversion.ts index 2f757c8..99fa4d9 100644 --- a/src/main-code/cyclic-conversion.ts +++ b/src/main-code/cyclic-conversion.ts @@ -3,6 +3,7 @@ import { EOL } from "../type-definition/EOLType"; import { cyclicConvertCaseOrder } from "../type-definition/SupportCaseType"; import { caseConversion } from "./conversion"; import { isStringArrayEqual, stringListArrayDuplicateRemoval } from './utils'; +import { getUserConfigurations } from './user-configuration'; interface UserSelection { currentEol: EOL @@ -64,16 +65,25 @@ function lazyConvert() { return; } + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + const textList = userSelection.currentSelectionsText; // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n')); const eol = userSelection.currentEol; const conversionsTarget: Array = [textList]; for (const cyclicConvertCase of cyclicConvertCaseOrder) { + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 跳过禁用的目标格式 + if (disableFormatList.includes(cyclicConvertCase.settingsKey)) { + continue; + } + // 每一个类型 const conversionsTargetItem: string[] = []; for (const line of textList) { // 选中区块的每一行 - const conversionResult: string = caseConversion(cyclicConvertCase, line, eol); + const conversionResult: string = caseConversion(cyclicConvertCase.type, line, eol); conversionsTargetItem.push(conversionResult); } conversionsTarget.push(conversionsTargetItem); diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index a6f0706..453e6e0 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -544,33 +544,38 @@ export const quickPickSupportCases: Array = [ }, ]; +export interface CyclicConvertCaseOrderItem { + type: SupportCase, + settingsKey: string, +} + /** * 通过快捷键循环转换的顺序 * @since 2024-04-08 */ -export const cyclicConvertCaseOrder = [ - SupportCase.CAMEL_CASE, - SupportCase.SNAKE_CASE, - SupportCase.PASCAL_CASE, - SupportCase.KEBAB_CASE, - SupportCase.SPACE_CASE, - SupportCase.DOT_CASE, +export const cyclicConvertCaseOrder: Array = [ + { type: SupportCase.CAMEL_CASE, settingsKey: 'camel_case' }, + { type: SupportCase.SNAKE_CASE, settingsKey: 'snake_case' }, + { type: SupportCase.PASCAL_CASE, settingsKey: 'pascal_case' }, + { type: SupportCase.KEBAB_CASE, settingsKey: 'kebab_case' }, + { type: SupportCase.SPACE_CASE, settingsKey: 'space_case' }, + { type: SupportCase.DOT_CASE, settingsKey: 'dot_case' }, - SupportCase.SNAKE_UPPER_CASE, - SupportCase.KEBAB_UPPER_CASE, - SupportCase.SPACE_UPPER_CASE, - SupportCase.DOT_UPPER_CASE, + { type: SupportCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' }, + { type: SupportCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' }, + { type: SupportCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' }, + { type: SupportCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' }, - SupportCase.SNAKE_PASCAL_CASE, - SupportCase.KEBAB_PASCAL_CASE, - SupportCase.SPACE_PASCAL_CASE, - SupportCase.DOT_PASCAL_CASE, + { type: SupportCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' }, + { type: SupportCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' }, + { type: SupportCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' }, + { type: SupportCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' }, - SupportCase.SNAKE_CAMEL_CASE, - SupportCase.KEBAB_CAMEL_CASE, - SupportCase.SPACE_CAMEL_CASE, - SupportCase.DOT_CAMEL_CASE, + { type: SupportCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' }, + { type: SupportCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' }, + { type: SupportCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' }, + { type: SupportCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' }, - SupportCase.LOWER_CASE, - SupportCase.UPPER_CASE, + { type: SupportCase.LOWER_CASE, settingsKey: 'lower_case' }, + { type: SupportCase.UPPER_CASE, settingsKey: 'upper_case' }, ]; From d07981febdd2e5a66d5f517532dc4a58bd1a6df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 23:05:56 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E5=8F=91=E7=89=88?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E9=9A=90=E8=97=8F=E6=9C=AA=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=9A=84=20variable-conversion.circularConve?= =?UTF-8?q?rsionFormatOrder=20=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 75 ---------------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/package.json b/package.json index c08753e..9606d25 100644 --- a/package.json +++ b/package.json @@ -317,81 +317,6 @@ }, "default": [], "markdownDescription": "Define which formats are disabled.\n\n定义哪些格式是禁用的\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\n[Restart Extension Host (重启扩展宿主)](command:workbench.action.restartExtensionHost), [Reload Window (重启当前窗口)](command:workbench.action.reloadWindow)" - }, - "variable-conversion.circularConversionFormatOrder": { - "order": 2, - "title": "定义循环转换快捷键的目标格式排序", - "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 🐳Default value 默认值: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", - "type": "array", - "items": { - "type": "string", - "enum": [ - "camel_case", - "pascal_case", - "snake_case", - "snake_camel_case", - "snake_pascal_case", - "snake_upper_case", - "kebab_case", - "kebab_camel_case", - "kebab_pascal_case", - "kebab_upper_case", - "space_case", - "space_camel_case", - "space_pascal_case", - "space_upper_case", - "dot_case", - "dot_camel_case", - "dot_pascal_case", - "dot_upper_case", - "lower_case", - "upper_case" - ], - "enumDescriptions": [ - "小驼峰(驼峰)命名", - "大驼峰(帕斯卡)命名", - "下划线(蛇形)命名", - "下划线(蛇形) + 小驼峰(驼峰)命名", - "下划线(蛇形) + 大驼峰(帕斯卡)命名", - "下划线(蛇形) + 全大写命名", - "中划线(连字符/脊柱式)命名", - "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", - "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", - "中划线(连字符/脊柱式) + 全大写命名", - "空格分隔命名", - "空格分隔 + 小驼峰(驼峰)命名", - "空格分隔 + 大驼峰(帕斯卡)命名", - "空格分隔 + 全大写命名", - "点分隔命名", - "点分隔 + 小驼峰(驼峰)命名", - "点分隔 + 大驼峰(帕斯卡)命名", - "点分隔 + 全大写命名", - "全小写", - "全大写" - ] - }, - "default": [ - "camel_case", - "snake_case", - "pascal_case", - "kebab_case", - "space_case", - "dot_case", - "snake_upper_case", - "kebab_upper_case", - "space_upper_case", - "dot_upper_case", - "snake_pascal_case", - "kebab_pascal_case", - "space_pascal_case", - "dot_pascal_case", - "snake_camel_case", - "kebab_camel_case", - "space_camel_case", - "dot_camel_case", - "lower_case", - "upper_case" - ] } } } From 8cf0bae1d0477c3d0d2680c1468b07fd38cf5f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 23:14:32 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E8=B0=83=E6=95=B4=EF=BC=9A=E4=B8=AD=E6=96=87=E5=9C=A8?= =?UTF-8?q?=E5=89=8D=E8=8B=B1=E6=96=87=E5=9C=A8=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-comment.jsonc | 8 ++++---- package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-comment.jsonc b/package-comment.jsonc index f8d9de9..1128d35 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -404,6 +404,8 @@ // camel_case(小驼峰), snake_camel_case(下划线), kebab_camel_case(连字符), space_camel_case(空格), dot_camel_case(点) "variable-conversion.disableFormat": { "order": 1, + // markdownDescription 最多配置 11 行 + "markdownDescription": "定义哪些格式是禁用的\n\nDefine which formats are disabled.\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n[重启扩展宿主 (Restart Extension Host)](command:workbench.action.restartExtensionHost), [重启当前窗口 (Reload Window)](command:workbench.action.reloadWindow)", "type": "array", "items": { "type": "string", @@ -452,9 +454,7 @@ "全大写" ] }, - "default": [], - // markdownDescription 最多配置 11 行 - "markdownDescription": "Define which formats are disabled.\n\n定义哪些格式是禁用的\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\n[Restart Extension Host (重启扩展宿主)](command:workbench.action.restartExtensionHost), [Reload Window (重启当前窗口)](command:workbench.action.reloadWindow)" + "default": [] }, "variable-conversion.circularConversionFormatOrder": { "order": 2, @@ -462,7 +462,7 @@ // "description": "Defines the destination format ordering of the circular conversion shortcut.\n定义循环转换快捷键的目标格式排序", // markdownDescription 最多配置 11 行 // "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", - "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 🐳Default value 默认值: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", + "markdownDescription": "定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 🐳默认值 Default value: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", // "type": "string", // "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" "type": "array", diff --git a/package.json b/package.json index 9606d25..d0e73f6 100644 --- a/package.json +++ b/package.json @@ -267,6 +267,7 @@ "properties": { "variable-conversion.disableFormat": { "order": 1, + "markdownDescription": "定义哪些格式是禁用的\n\nDefine which formats are disabled.\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n[重启扩展宿主 (Restart Extension Host)](command:workbench.action.restartExtensionHost), [重启当前窗口 (Reload Window)](command:workbench.action.reloadWindow)", "type": "array", "items": { "type": "string", @@ -315,8 +316,7 @@ "全大写" ] }, - "default": [], - "markdownDescription": "Define which formats are disabled.\n\n定义哪些格式是禁用的\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\n[Restart Extension Host (重启扩展宿主)](command:workbench.action.restartExtensionHost), [Reload Window (重启当前窗口)](command:workbench.action.reloadWindow)" + "default": [] } } } From bcecab5425b5902e7346bbddb1b00a931131dfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 23:35:37 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md=20=E8=87=AA?= =?UTF-8?q?=E8=BF=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d5e5db..63bc720 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Select what you want to convert in the editor, and then press `Ctrl + Alt + [` o ![](image/cyclic-conversion.gif) -### 基础转换 +### 基础转换 Basic conversion **1. 选中代码中需要转换的内容** **Select The Text To Convert** @@ -47,7 +47,7 @@ Or right-click on the selected text -> Convert string to... **3. 选择转换目标,转换完成** **Select the conversion target and complete** -## 快捷键 +## 快捷键 Shortcut key | 功能 Feature | 快捷键 shortcut key | | ------------------------------------------------ | ------------------- | @@ -55,6 +55,12 @@ Or right-click on the selected text -> Convert string to... | 循环转换→上一个 Cyclic conversion → Previous one | Ctrl + Alt + [ | | 循环转换→下一个 Cyclic conversion → Next one | Ctrl + Alt + ] | +## 配置项 configurations + +| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 | +| ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | ------ | +| `variable-conversion.disableFormat` | 定义哪些格式是禁用的
Define which formats are disabled. | `["lower_case", "upper_case"]` | `[]` | + ## 支持的类型 Support Case | 类型 | Case | 举例 e.g. | @@ -82,7 +88,7 @@ Or right-click on the selected text -> Convert string to... ## 小提示 Tips -#### 关于文本选区... +#### 关于文本选区... About text selections... - 可以先按住 `Alt` 键不放,再鼠标先后选中多个选区 You can first hold down `Alt`, and then use the mouse to select multiple selection @@ -107,4 +113,6 @@ Gitee Mirror (码云镜像): https://gitee.com/coder-xiaomo/variable-conversion- ----- +**玩得开心!** + **Enjoy!** From 9021df5ea8e5ed238ba0acc32377318b63e8bfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <16949192+coder-xiaomo@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:39:18 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87VSCode?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=85=8D=E7=BD=AE=E5=93=AA=E4=BA=9B?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=98=AF=E7=A6=81=E7=94=A8=E7=9A=84=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加 VSCode 配置项 (逻辑待实现) * QuickPick 菜单支持过滤用户配置的禁用格式 (disableFormat) * 右键菜单支持过滤用户配置的禁用格式 (disableFormat) * 快捷键循环转换支持过滤用户配置的禁用格式 (disableFormat) * 为了发版暂时隐藏未开发完成的 variable-conversion.circularConversionFormatOrder 配置项 * 配置项描述调整:中文在前英文在后 * 更新 README.md 自述文档 --- README.md | 14 +- package-comment.jsonc | 191 +++++++++++++++++- package.json | 84 +++++++- src/extension-handler/quick-pick-handler.ts | 27 ++- src/extension.ts | 9 + src/main-code/cyclic-conversion.ts | 12 +- src/main-code/user-configuration.ts | 14 ++ src/type-definition/SupportCaseType.ts | 211 +++++++++++++++----- 8 files changed, 500 insertions(+), 62 deletions(-) create mode 100644 src/main-code/user-configuration.ts diff --git a/README.md b/README.md index 7d5e5db..63bc720 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Select what you want to convert in the editor, and then press `Ctrl + Alt + [` o ![](image/cyclic-conversion.gif) -### 基础转换 +### 基础转换 Basic conversion **1. 选中代码中需要转换的内容** **Select The Text To Convert** @@ -47,7 +47,7 @@ Or right-click on the selected text -> Convert string to... **3. 选择转换目标,转换完成** **Select the conversion target and complete** -## 快捷键 +## 快捷键 Shortcut key | 功能 Feature | 快捷键 shortcut key | | ------------------------------------------------ | ------------------- | @@ -55,6 +55,12 @@ Or right-click on the selected text -> Convert string to... | 循环转换→上一个 Cyclic conversion → Previous one | Ctrl + Alt + [ | | 循环转换→下一个 Cyclic conversion → Next one | Ctrl + Alt + ] | +## 配置项 configurations + +| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 | +| ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | ------ | +| `variable-conversion.disableFormat` | 定义哪些格式是禁用的
Define which formats are disabled. | `["lower_case", "upper_case"]` | `[]` | + ## 支持的类型 Support Case | 类型 | Case | 举例 e.g. | @@ -82,7 +88,7 @@ Or right-click on the selected text -> Convert string to... ## 小提示 Tips -#### 关于文本选区... +#### 关于文本选区... About text selections... - 可以先按住 `Alt` 键不放,再鼠标先后选中多个选区 You can first hold down `Alt`, and then use the mouse to select multiple selection @@ -107,4 +113,6 @@ Gitee Mirror (码云镜像): https://gitee.com/coder-xiaomo/variable-conversion- ----- +**玩得开心!** + **Enjoy!** diff --git a/package-comment.jsonc b/package-comment.jsonc index bd6ece6..1128d35 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -225,87 +225,107 @@ "variable-conversion.stringConversionMenu": [ // group-1-camel { + "when": "!_isHideSubMenuItem_camel_case", "command": "variable-conversion.toCamelCase", "group": "group-1-camel@1" }, { + "when": "!_isHideSubMenuItem_pascal_case", "command": "variable-conversion.toPascalCase", "group": "group-1-camel@2" }, // group-2-snake { + "when": "!_isHideSubMenuItem_snake_case", "command": "variable-conversion.toSnakeCase", "group": "group-2-snake@1" }, { + "when": "!_isHideSubMenuItem_snake_upper_case", "command": "variable-conversion.toSnakeUpperCase", "group": "group-2-snake@2" }, { + "when": "!_isHideSubMenuItem_snake_pascal_case", "command": "variable-conversion.toSnakePascalCase", "group": "group-2-snake@3" }, { + "when": "!_isHideSubMenuItem_snake_camel_case", "command": "variable-conversion.toSnakeCamelCase", "group": "group-2-snake@4" }, // group-3-kebab { + "when": "!_isHideSubMenuItem_kebab_case", "command": "variable-conversion.toKebabCase", "group": "group-3-kebab@1" }, { + "when": "!_isHideSubMenuItem_kebab_upper_case", "command": "variable-conversion.toKebabUpperCase", "group": "group-3-kebab@2" }, { + "when": "!_isHideSubMenuItem_kebab_pascal_case", "command": "variable-conversion.toKebabPascalCase", "group": "group-3-kebab@3" }, { + "when": "!_isHideSubMenuItem_kebab_camel_case", "command": "variable-conversion.toKebabCamelCase", "group": "group-3-kebab@4" }, // group-4-space { + "when": "!_isHideSubMenuItem_space_case", "command": "variable-conversion.toSpaceCase", "group": "group-4-space@1" }, { + "when": "!_isHideSubMenuItem_space_upper_case", "command": "variable-conversion.toSpaceUpperCase", "group": "group-4-space@2" }, { + "when": "!_isHideSubMenuItem_space_pascal_case", "command": "variable-conversion.toSpacePascalCase", "group": "group-4-space@3" }, { + "when": "!_isHideSubMenuItem_space_camel_case", "command": "variable-conversion.toSpaceCamelCase", "group": "group-4-space@4" }, // group-5-dot { + "when": "!_isHideSubMenuItem_dot_case", "command": "variable-conversion.toDotCase", "group": "group-5-dot@1" }, { + "when": "!_isHideSubMenuItem_dot_upper_case", "command": "variable-conversion.toDotUpperCase", "group": "group-5-dot@2" }, { + "when": "!_isHideSubMenuItem_dot_pascal_case", "command": "variable-conversion.toDotPascalCase", "group": "group-5-dot@3" }, { + "when": "!_isHideSubMenuItem_dot_camel_case", "command": "variable-conversion.toDotCamelCase", "group": "group-5-dot@4" }, // group-6-upper-lower { + "when": "!_isHideSubMenuItem_lower_case", "command": "variable-conversion.toLowerCase", "group": "group-6-upper-lower@1" }, { + "when": "!_isHideSubMenuItem_upper_case", "command": "variable-conversion.toUpperCase", "group": "group-6-upper-lower@2" } @@ -348,7 +368,176 @@ "id": "variable-conversion.stringConversionMenu", "label": "将变量转换为..." } - ] + ], + // docs: https://code.visualstudio.com/api/references/contribution-points#contributes.configuration + "configuration": { + "title": "Variable Conversion 变量转换", + "properties": { + // 仅测试用 + // "variable-conversion.test1": { + // "title": "定义转换格式的排序", + // "description": "Defines the ordering of the conversion format.\n定义转换格式的排序", + // "type": "array", + // "default": [ + // "camelCase", + // "snake_case", + // "PascalCase" + // ] + // }, + // "variable-conversion.enableFormat": { + // "type": "object", + // "default": { + // "camelCase": true, + // "snake_case": true, + // "PascalCase": true + // }, + // "description": "Define which formats are enabled.\n定义哪些格式是开启的" + // }, + // + // 全小写命名 + // lower_case(全小写), snake_case(下划线), kebab_case(连字符), space_case(空格), dot_case(点) + // 全大写命名 + // upper_case(全大写), snake_upper_case(下划线), kebab_upper_case(连字符), space_upper_case(空格), dot_upper_case(点) + // 大驼峰命名 + // pascal_case(大驼峰), snake_pascal_case(下划线), kebab_pascal_case(连字符), space_pascal_case(空格), dot_pascal_case(点) + // 小驼峰命名 + // camel_case(小驼峰), snake_camel_case(下划线), kebab_camel_case(连字符), space_camel_case(空格), dot_camel_case(点) + "variable-conversion.disableFormat": { + "order": 1, + // markdownDescription 最多配置 11 行 + "markdownDescription": "定义哪些格式是禁用的\n\nDefine which formats are disabled.\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n[重启扩展宿主 (Restart Extension Host)](command:workbench.action.restartExtensionHost), [重启当前窗口 (Reload Window)](command:workbench.action.reloadWindow)", + "type": "array", + "items": { + "type": "string", + "enum": [ + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" + ] + }, + "default": [] + }, + "variable-conversion.circularConversionFormatOrder": { + "order": 2, + "title": "定义循环转换快捷键的目标格式排序", + // "description": "Defines the destination format ordering of the circular conversion shortcut.\n定义循环转换快捷键的目标格式排序", + // markdownDescription 最多配置 11 行 + // "markdownDescription": "Defines the destination format ordering of the circular conversion shortcut, separated by commas.\n\n 定义循环转换快捷键的目标格式排序,以英文逗号分隔\n\n Target formats that are not in the following configuration list will appear last in the following custom order in the default order.\n\n不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)\n\n🐳Default value 默认值: `camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case`\n\n If you find the following configuration troublesome, you can also edit this configuration item in `settings.json`. 若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑: `\"variable-conversion.circularConversionFormatOrder\": \"...\",` [Edit in settings.json (在 settings.json 中编辑)](command:workbench.action.openSettingsJson)", + "markdownDescription": "定义循环转换快捷键的目标格式排序,以英文逗号分隔。不在以下配置列表中的目标格式,将按照默认顺序排在以下自定义顺序最后\n\n Defines the destination format ordering of the circular conversion shortcut, separated by commas. (Target formats that are not in the following configuration list will appear last in the following custom order in the default order.)\n\n 📌请[在 `settings.json` 中编辑该配置](command:workbench.action.openSettingsJson),**不要使用**设置页面的下拉框进行配置: `\"variable-conversion.circularConversionFormatOrder\": [ ... ],`\n\n 📌Please [edit this configuration in `settings.json`](command:workbench.action.openSettingsJson), **instead of** using the drop-down box on the settings page.\n\n 🐳默认值 Default value: `\"variable-conversion.circularConversionFormatOrder\": [ \"camel_case\", \"snake_case\", \"pascal_case\", \"kebab_case\", \"space_case\", \"dot_case\", \"snake_upper_case\", \"kebab_upper_case\", \"space_upper_case\", \"dot_upper_case\", \"snake_pascal_case\", \"kebab_pascal_case\", \"space_pascal_case\", \"dot_pascal_case\", \"snake_camel_case\", \"kebab_camel_case\", \"space_camel_case\", \"dot_camel_case\", \"lower_case\", \"upper_case\" ],`\n\n 👉Configuration item meaning 配置项说明\n\n 🌟Lower Case 全小写命名: `lower_case`(全小写), `snake_case`(下划线), `kebab_case`(连字符), `space_case`(空格), `dot_case`(点)\n\n 🌟Upper Case 全大写命名: `upper_case`(全大写), `snake_upper_case`(下划线), `kebab_upper_case`(连字符), `space_upper_case`(空格), `dot_upper_case`(点)\n\n 🌟Pascal Case 大驼峰命名: `pascal_case`(大驼峰), `snake_pascal_case`(下划线), `kebab_pascal_case`(连字符), `space_pascal_case`(空格), `dot_pascal_case`(点)\n\n 🌟Camel Case 小驼峰命名: `camel_case`(小驼峰), `snake_camel_case`(下划线), `kebab_camel_case`(连字符), `space_camel_case`(空格), `dot_camel_case`(点)", + // "type": "string", + // "default": "camel_case, snake_case, pascal_case, kebab_case, space_case, dot_case, snake_upper_case, kebab_upper_case, space_upper_case, dot_upper_case, snake_pascal_case, kebab_pascal_case, space_pascal_case, dot_pascal_case, snake_camel_case, kebab_camel_case, space_camel_case, dot_camel_case, lower_case, upper_case" + "type": "array", + "items": { + "type": "string", + "enum": [ + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" + ] + }, + "default": [ + "camel_case", + "snake_case", + "pascal_case", + "kebab_case", + "space_case", + "dot_case", + "snake_upper_case", + "kebab_upper_case", + "space_upper_case", + "dot_upper_case", + "snake_pascal_case", + "kebab_pascal_case", + "space_pascal_case", + "dot_pascal_case", + "snake_camel_case", + "kebab_camel_case", + "space_camel_case", + "dot_camel_case", + "lower_case", + "upper_case" + ] + } + } + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/package.json b/package.json index 9859852..d0e73f6 100644 --- a/package.json +++ b/package.json @@ -155,84 +155,104 @@ ], "variable-conversion.stringConversionMenu": [ { + "when": "!_isHideSubMenuItem_camel_case", "command": "variable-conversion.toCamelCase", "group": "group-1-camel@1" }, { + "when": "!_isHideSubMenuItem_pascal_case", "command": "variable-conversion.toPascalCase", "group": "group-1-camel@2" }, { + "when": "!_isHideSubMenuItem_snake_case", "command": "variable-conversion.toSnakeCase", "group": "group-2-snake@1" }, { + "when": "!_isHideSubMenuItem_snake_upper_case", "command": "variable-conversion.toSnakeUpperCase", "group": "group-2-snake@2" }, { + "when": "!_isHideSubMenuItem_snake_pascal_case", "command": "variable-conversion.toSnakePascalCase", "group": "group-2-snake@3" }, { + "when": "!_isHideSubMenuItem_snake_camel_case", "command": "variable-conversion.toSnakeCamelCase", "group": "group-2-snake@4" }, { + "when": "!_isHideSubMenuItem_kebab_case", "command": "variable-conversion.toKebabCase", "group": "group-3-kebab@1" }, { + "when": "!_isHideSubMenuItem_kebab_upper_case", "command": "variable-conversion.toKebabUpperCase", "group": "group-3-kebab@2" }, { + "when": "!_isHideSubMenuItem_kebab_pascal_case", "command": "variable-conversion.toKebabPascalCase", "group": "group-3-kebab@3" }, { + "when": "!_isHideSubMenuItem_kebab_camel_case", "command": "variable-conversion.toKebabCamelCase", "group": "group-3-kebab@4" }, { + "when": "!_isHideSubMenuItem_space_case", "command": "variable-conversion.toSpaceCase", "group": "group-4-space@1" }, { + "when": "!_isHideSubMenuItem_space_upper_case", "command": "variable-conversion.toSpaceUpperCase", "group": "group-4-space@2" }, { + "when": "!_isHideSubMenuItem_space_pascal_case", "command": "variable-conversion.toSpacePascalCase", "group": "group-4-space@3" }, { + "when": "!_isHideSubMenuItem_space_camel_case", "command": "variable-conversion.toSpaceCamelCase", "group": "group-4-space@4" }, { + "when": "!_isHideSubMenuItem_dot_case", "command": "variable-conversion.toDotCase", "group": "group-5-dot@1" }, { + "when": "!_isHideSubMenuItem_dot_upper_case", "command": "variable-conversion.toDotUpperCase", "group": "group-5-dot@2" }, { + "when": "!_isHideSubMenuItem_dot_pascal_case", "command": "variable-conversion.toDotPascalCase", "group": "group-5-dot@3" }, { + "when": "!_isHideSubMenuItem_dot_camel_case", "command": "variable-conversion.toDotCamelCase", "group": "group-5-dot@4" }, { + "when": "!_isHideSubMenuItem_lower_case", "command": "variable-conversion.toLowerCase", - "group": "group-5-upper-lower@1" + "group": "group-6-upper-lower@1" }, { + "when": "!_isHideSubMenuItem_upper_case", "command": "variable-conversion.toUpperCase", - "group": "group-5-upper-lower@2" + "group": "group-6-upper-lower@2" } ] }, @@ -241,7 +261,65 @@ "id": "variable-conversion.stringConversionMenu", "label": "将变量转换为..." } - ] + ], + "configuration": { + "title": "Variable Conversion 变量转换", + "properties": { + "variable-conversion.disableFormat": { + "order": 1, + "markdownDescription": "定义哪些格式是禁用的\n\nDefine which formats are disabled.\n\n若您感觉以下配置比较麻烦,也可以选择在 `settings.json` 中编辑:\n\nIf you find the following configuration troublesome, you can also edit this configuration item in `settings.json`:\n\n`\"variable-conversion.disableFormat\": [ ... ],`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n配置后,您可能需要*重启扩展宿主*,或*重启当前窗口*才可使该配置完全生效(二选一即可):\n\nYou may need to *restart extension host* or *reload window* after configuration to take full effect (either):\n\n[重启扩展宿主 (Restart Extension Host)](command:workbench.action.restartExtensionHost), [重启当前窗口 (Reload Window)](command:workbench.action.reloadWindow)", + "type": "array", + "items": { + "type": "string", + "enum": [ + "camel_case", + "pascal_case", + "snake_case", + "snake_camel_case", + "snake_pascal_case", + "snake_upper_case", + "kebab_case", + "kebab_camel_case", + "kebab_pascal_case", + "kebab_upper_case", + "space_case", + "space_camel_case", + "space_pascal_case", + "space_upper_case", + "dot_case", + "dot_camel_case", + "dot_pascal_case", + "dot_upper_case", + "lower_case", + "upper_case" + ], + "enumDescriptions": [ + "小驼峰(驼峰)命名", + "大驼峰(帕斯卡)命名", + "下划线(蛇形)命名", + "下划线(蛇形) + 小驼峰(驼峰)命名", + "下划线(蛇形) + 大驼峰(帕斯卡)命名", + "下划线(蛇形) + 全大写命名", + "中划线(连字符/脊柱式)命名", + "中划线(连字符/脊柱式) + 小驼峰(驼峰)命名", + "中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名", + "中划线(连字符/脊柱式) + 全大写命名", + "空格分隔命名", + "空格分隔 + 小驼峰(驼峰)命名", + "空格分隔 + 大驼峰(帕斯卡)命名", + "空格分隔 + 全大写命名", + "点分隔命名", + "点分隔 + 小驼峰(驼峰)命名", + "点分隔 + 大驼峰(帕斯卡)命名", + "点分隔 + 全大写命名", + "全小写", + "全大写" + ] + }, + "default": [] + } + } + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/src/extension-handler/quick-pick-handler.ts b/src/extension-handler/quick-pick-handler.ts index 5ef9c59..295cc2a 100644 --- a/src/extension-handler/quick-pick-handler.ts +++ b/src/extension-handler/quick-pick-handler.ts @@ -1,11 +1,12 @@ import * as vscode from 'vscode'; import QuickPickItemEx from "../type-definition/QuickPickItemExType"; -import { quickPickSupportCases } from '../type-definition/SupportCaseType'; +import { QuickPickSupportCaseItem, quickPickSupportCases } from '../type-definition/SupportCaseType'; import { TransformTextResult } from '../type-definition/TransformTextResultType'; -import { transformMutliLineText, transformMutliSelectionText } from '../main-code/transform'; +import { transformMutliSelectionText } from '../main-code/transform'; import { EOL } from '../type-definition/EOLType'; import { caseConversion } from '../main-code/conversion'; import { isStringArrayEqual } from '../main-code/utils'; +import { getUserConfigurations } from '../main-code/user-configuration'; const QuickPickLabelMaxLength = 60; @@ -18,12 +19,12 @@ interface RecommendItem { /** * 弹出的提示 */ -function generateOptionsBasedOnText(textList: string[], eol: EOL): Array { +function generateOptionsBasedOnText(textList: string[], eol: EOL, enabledQuickPickSupportCases: Array): Array { // Cut text 切割文本 const resultsList: Array = transformMutliSelectionText(textList); const mergeResultList: Array = []; - for (const quickPick of quickPickSupportCases) { + for (const quickPick of enabledQuickPickSupportCases) { const conversionResults: Array = []; for (let i = 0; i < textList.length; i++) { const text = textList[i]; @@ -95,8 +96,24 @@ export function handleQuickPick() { return; } + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + // 排除禁用的选项 + const enabledQuickPickSupportCases = []; + for (const quickPick of quickPickSupportCases) { + if (disableFormatList.includes(quickPick.settingsKey)) { + continue; + } + enabledQuickPickSupportCases.push(quickPick); + } + if (enabledQuickPickSupportCases.length === 0) { + vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.disableFormat` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.disableFormat` configuration and try again.'); + return; + } + // 基于选中的文本生成选项 - const options = generateOptionsBasedOnText(textList, eol); + const options = generateOptionsBasedOnText(textList, eol, enabledQuickPickSupportCases); if (options.length === 0) { vscode.window.showInformationMessage('所选内容暂无可选转换,请尝试重新选择\nNo conversion candidates are available for the selected content, please try to select another text.'); return; diff --git a/src/extension.ts b/src/extension.ts index f99605c..5e6464f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,6 +7,7 @@ import { commands } from './type-definition/SupportCaseType'; import { createStatusBarItem, updateStatusBarItemVisable } from './extension-handler/status-bar-handler'; import * as CyclicConversion from './main-code/cyclic-conversion'; import { EOL } from './type-definition/EOLType'; +import { getUserConfigurations } from './main-code/user-configuration'; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -41,6 +42,14 @@ export function activate(context: vscode.ExtensionContext) { // 更新 _textSelectionLength (用于判断是否展示右键菜单) vscode.commands.executeCommand('setContext', '_textSelectionLength', selectTextLength); + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + // 更新右键菜单每一项是否展示 + for (const { settingsKey } of commands) { + vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); + } + // 判断是否展示状态栏按钮 updateStatusBarItemVisable(selectTextLength); diff --git a/src/main-code/cyclic-conversion.ts b/src/main-code/cyclic-conversion.ts index 2f757c8..99fa4d9 100644 --- a/src/main-code/cyclic-conversion.ts +++ b/src/main-code/cyclic-conversion.ts @@ -3,6 +3,7 @@ import { EOL } from "../type-definition/EOLType"; import { cyclicConvertCaseOrder } from "../type-definition/SupportCaseType"; import { caseConversion } from "./conversion"; import { isStringArrayEqual, stringListArrayDuplicateRemoval } from './utils'; +import { getUserConfigurations } from './user-configuration'; interface UserSelection { currentEol: EOL @@ -64,16 +65,25 @@ function lazyConvert() { return; } + // 获取用户配置 + const disableFormatList = getUserConfigurations('disableFormat'); + const textList = userSelection.currentSelectionsText; // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n')); const eol = userSelection.currentEol; const conversionsTarget: Array = [textList]; for (const cyclicConvertCase of cyclicConvertCaseOrder) { + // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 + // 跳过禁用的目标格式 + if (disableFormatList.includes(cyclicConvertCase.settingsKey)) { + continue; + } + // 每一个类型 const conversionsTargetItem: string[] = []; for (const line of textList) { // 选中区块的每一行 - const conversionResult: string = caseConversion(cyclicConvertCase, line, eol); + const conversionResult: string = caseConversion(cyclicConvertCase.type, line, eol); conversionsTargetItem.push(conversionResult); } conversionsTarget.push(conversionsTargetItem); diff --git a/src/main-code/user-configuration.ts b/src/main-code/user-configuration.ts new file mode 100644 index 0000000..4a9d106 --- /dev/null +++ b/src/main-code/user-configuration.ts @@ -0,0 +1,14 @@ +const vscode = require('vscode'); + +function getUserConfigurations(configKey: string) { + const config = vscode.workspace.getConfiguration('variable-conversion'); + + // 获取 disableFormat 配置项 + const configValue = config.get(configKey); + console.log('configValue:', configValue); + return configValue; +} + +export { + getUserConfigurations +}; diff --git a/src/type-definition/SupportCaseType.ts b/src/type-definition/SupportCaseType.ts index e4b2418..453e6e0 100644 --- a/src/type-definition/SupportCaseType.ts +++ b/src/type-definition/SupportCaseType.ts @@ -3,7 +3,7 @@ * * Code: * - Add type definition in below `SupportCase` enum and following array - * - Add `commands`, `menus` parts in [package.json] and [package-comment.jsonc] + * - Add `commands`, `menus`, `configuration` parts in [package.json] and [package-comment.jsonc] * - Add main conversion logic in [src/main-code/conversion.ts] * * Test: @@ -281,188 +281,301 @@ 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.toDotCase', targetCase: SupportCase.DOT_CASE }, - { command: 'variable-conversion.toDotUpperCase', targetCase: SupportCase.DOT_UPPER_CASE }, - { command: 'variable-conversion.toDotPascalCase', targetCase: SupportCase.DOT_PASCAL_CASE }, - { command: 'variable-conversion.toDotCamelCase', targetCase: SupportCase.DOT_CAMEL_CASE }, - - { command: 'variable-conversion.toLowerCase', targetCase: SupportCase.LOWER_CASE }, - { command: 'variable-conversion.toUpperCase', targetCase: SupportCase.UPPER_CASE }, +export const commands: Array<{ command: string; targetCase: SupportCase; settingsKey: string }> = [ + { + command: 'variable-conversion.toCamelCase', + targetCase: SupportCase.CAMEL_CASE, + settingsKey: 'camel_case' + }, + { + command: 'variable-conversion.toPascalCase', + targetCase: SupportCase.PASCAL_CASE, + settingsKey: 'pascal_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toSnakeCase', + targetCase: SupportCase.SNAKE_CASE, + settingsKey: 'snake_case' + }, + { + command: 'variable-conversion.toSnakeUpperCase', + targetCase: SupportCase.SNAKE_UPPER_CASE, + settingsKey: 'snake_upper_case' + }, + { + command: 'variable-conversion.toSnakePascalCase', + targetCase: SupportCase.SNAKE_PASCAL_CASE, + settingsKey: 'snake_pascal_case' + }, + { + command: 'variable-conversion.toSnakeCamelCase', + targetCase: SupportCase.SNAKE_CAMEL_CASE, + settingsKey: 'snake_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toKebabCase', + targetCase: SupportCase.KEBAB_CASE, + settingsKey: 'kebab_case' + }, + { + command: 'variable-conversion.toKebabUpperCase', + targetCase: SupportCase.KEBAB_UPPER_CASE, + settingsKey: 'kebab_upper_case' + }, + { + command: 'variable-conversion.toKebabPascalCase', + targetCase: SupportCase.KEBAB_PASCAL_CASE, + settingsKey: 'kebab_pascal_case' + }, + { + command: 'variable-conversion.toKebabCamelCase', + targetCase: SupportCase.KEBAB_CAMEL_CASE, + settingsKey: 'kebab_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toSpaceCase', + targetCase: SupportCase.SPACE_CASE, + settingsKey: 'space_case' + }, + { + command: 'variable-conversion.toSpaceUpperCase', + targetCase: SupportCase.SPACE_UPPER_CASE, + settingsKey: 'space_upper_case' + }, + { + command: 'variable-conversion.toSpacePascalCase', + targetCase: SupportCase.SPACE_PASCAL_CASE, + settingsKey: 'space_pascal_case' + }, + { + command: 'variable-conversion.toSpaceCamelCase', + targetCase: SupportCase.SPACE_CAMEL_CASE, + settingsKey: 'space_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toDotCase', + targetCase: SupportCase.DOT_CASE, + settingsKey: 'dot_case' + }, + { + command: 'variable-conversion.toDotUpperCase', + targetCase: SupportCase.DOT_UPPER_CASE, + settingsKey: 'dot_upper_case' + }, + { + command: 'variable-conversion.toDotPascalCase', + targetCase: SupportCase.DOT_PASCAL_CASE, + settingsKey: 'dot_pascal_case' + }, + { + command: 'variable-conversion.toDotCamelCase', + targetCase: SupportCase.DOT_CAMEL_CASE, + settingsKey: 'dot_camel_case' + }, + // +++++++++++++++++++++++++++++++++++++++++++++++ + { + command: 'variable-conversion.toLowerCase', + targetCase: SupportCase.LOWER_CASE, + settingsKey: 'lower_case' + }, + { + command: 'variable-conversion.toUpperCase', + targetCase: SupportCase.UPPER_CASE, + settingsKey: 'upper_case' + }, ]; +export interface QuickPickSupportCaseItem { + type: SupportCase, + name: string, + shortName: string, + keyword: string[], + settingsKey: string, +} + /** * 所有支持的命名方式 * @since 2024-04-06 */ -export const quickPickSupportCases = [ +export const quickPickSupportCases: Array = [ { type: SupportCase.CAMEL_CASE, name: '小驼峰(驼峰)命名', shortName: '小驼峰', keyword: keyword.camel, + settingsKey: 'camel_case', }, { type: SupportCase.PASCAL_CASE, name: '大驼峰(帕斯卡)命名', shortName: '帕斯卡', keyword: keyword.pascal, + settingsKey: 'pascal_case', }, { type: SupportCase.SNAKE_CASE, name: '下划线(蛇形)命名', shortName: '蛇形', keyword: [...keyword.snake, ...keyword.lower], + settingsKey: 'snake_case', }, { type: SupportCase.SNAKE_CAMEL_CASE, name: '下划线(蛇形) + 小驼峰(驼峰)命名', shortName: '蛇形驼峰', keyword: [...keyword.snake, ...keyword.camel], + settingsKey: 'snake_camel_case', }, { type: SupportCase.SNAKE_PASCAL_CASE, name: '下划线(蛇形) + 大驼峰(帕斯卡)命名', shortName: '蛇形帕斯卡', keyword: [...keyword.snake, ...keyword.pascal], + settingsKey: 'snake_pascal_case', }, { type: SupportCase.SNAKE_UPPER_CASE, name: '下划线(蛇形) + 全大写命名', shortName: '蛇形大写', keyword: [...keyword.snake, ...keyword.upper], + settingsKey: 'snake_upper_case', }, { type: SupportCase.KEBAB_CASE, name: '中划线(连字符/脊柱式)命名', shortName: '脊柱', keyword: [...keyword.kebab, ...keyword.lower], + settingsKey: 'kebab_case', }, { type: SupportCase.KEBAB_CAMEL_CASE, name: '中划线(连字符/脊柱式) + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.kebab, ...keyword.camel], + settingsKey: 'kebab_camel_case', }, { type: SupportCase.KEBAB_PASCAL_CASE, name: '中划线(连字符/脊柱式) + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.kebab, ...keyword.pascal], + settingsKey: 'kebab_pascal_case', }, { type: SupportCase.KEBAB_UPPER_CASE, name: '中划线(连字符/脊柱式) + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.kebab, ...keyword.upper], + settingsKey: 'kebab_upper_case', }, { type: SupportCase.SPACE_CASE, name: '空格分隔命名', shortName: '脊柱', keyword: [...keyword.space, ...keyword.lower], + settingsKey: 'space_case', }, { type: SupportCase.SPACE_CAMEL_CASE, name: '空格分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.space, ...keyword.camel], + settingsKey: 'space_camel_case', }, { type: SupportCase.SPACE_PASCAL_CASE, name: '空格分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.space, ...keyword.pascal], + settingsKey: 'space_pascal_case', }, { type: SupportCase.SPACE_UPPER_CASE, name: '空格分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.space, ...keyword.upper], + settingsKey: 'space_upper_case', }, { type: SupportCase.DOT_CASE, name: '点分隔命名', shortName: '脊柱', keyword: [...keyword.dot, ...keyword.lower], + settingsKey: 'dot_case', }, { type: SupportCase.DOT_CAMEL_CASE, name: '点分隔 + 小驼峰(驼峰)命名', shortName: '脊柱驼峰', keyword: [...keyword.dot, ...keyword.camel], + settingsKey: 'dot_camel_case', }, { type: SupportCase.DOT_PASCAL_CASE, name: '点分隔 + 大驼峰(帕斯卡)命名', shortName: '脊柱帕斯卡', keyword: [...keyword.dot, ...keyword.pascal], + settingsKey: 'dot_pascal_case', }, { type: SupportCase.DOT_UPPER_CASE, name: '点分隔 + 全大写命名', shortName: '脊柱大写', keyword: [...keyword.dot, ...keyword.upper], + settingsKey: 'dot_upper_case', }, { type: SupportCase.LOWER_CASE, name: '全小写', shortName: '小写', keyword: keyword.lower, + settingsKey: 'lower_case', }, { type: SupportCase.UPPER_CASE, name: '全大写', shortName: '大写', keyword: keyword.upper, + settingsKey: 'upper_case', }, ]; +export interface CyclicConvertCaseOrderItem { + type: SupportCase, + settingsKey: string, +} + /** * 通过快捷键循环转换的顺序 * @since 2024-04-08 */ -export const cyclicConvertCaseOrder = [ - SupportCase.CAMEL_CASE, - SupportCase.SNAKE_CASE, - SupportCase.PASCAL_CASE, - SupportCase.KEBAB_CASE, - SupportCase.SPACE_CASE, - SupportCase.DOT_CASE, +export const cyclicConvertCaseOrder: Array = [ + { type: SupportCase.CAMEL_CASE, settingsKey: 'camel_case' }, + { type: SupportCase.SNAKE_CASE, settingsKey: 'snake_case' }, + { type: SupportCase.PASCAL_CASE, settingsKey: 'pascal_case' }, + { type: SupportCase.KEBAB_CASE, settingsKey: 'kebab_case' }, + { type: SupportCase.SPACE_CASE, settingsKey: 'space_case' }, + { type: SupportCase.DOT_CASE, settingsKey: 'dot_case' }, - SupportCase.SNAKE_UPPER_CASE, - SupportCase.KEBAB_UPPER_CASE, - SupportCase.SPACE_UPPER_CASE, - SupportCase.DOT_UPPER_CASE, + { type: SupportCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' }, + { type: SupportCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' }, + { type: SupportCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' }, + { type: SupportCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' }, - SupportCase.SNAKE_PASCAL_CASE, - SupportCase.KEBAB_PASCAL_CASE, - SupportCase.SPACE_PASCAL_CASE, - SupportCase.DOT_PASCAL_CASE, + { type: SupportCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' }, + { type: SupportCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' }, + { type: SupportCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' }, + { type: SupportCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' }, - SupportCase.SNAKE_CAMEL_CASE, - SupportCase.KEBAB_CAMEL_CASE, - SupportCase.SPACE_CAMEL_CASE, - SupportCase.DOT_CAMEL_CASE, + { type: SupportCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' }, + { type: SupportCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' }, + { type: SupportCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' }, + { type: SupportCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' }, - SupportCase.LOWER_CASE, - SupportCase.UPPER_CASE, + { type: SupportCase.LOWER_CASE, settingsKey: 'lower_case' }, + { type: SupportCase.UPPER_CASE, settingsKey: 'upper_case' }, ]; From 7b4a0667e6e6f261371ee0a808c69153c67fc690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Mon, 29 Jul 2024 23:49:46 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=B8=BA=201.1.0=EF=BC=9B=E6=9B=B4=E6=96=B0=20CHANGEL?= =?UTF-8?q?OG.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 +++++++- package-comment.jsonc | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b521d30..fcd3ddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,11 +23,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --> +## 1.1.0 + +### Added + +- Support configuring which formats are disabled through the VSCode settings page. It will apply to QuickPick menu conversions, context menu conversions, and shortcut key cyclic conversions. (支持通过 VSCode 设置页配置哪些格式是禁用的。配置后将同时对 QuickPick 菜单转换、右键菜单转换、快捷键循环转换生效) + ## 1.0.11 ### Improvement -- Imperfect support: When a sub window is activated, clicking on the status bar of the main window can correctly bring up the QuickPick menu. 不完美支持:当子窗口激活时,点击主窗口状态栏能够正确弹出快速拾取菜单 +- Imperfect support: When a sub window is activated, clicking on the status bar of the main window can correctly bring up the QuickPick menu. (不完美支持:当子窗口激活时,点击主窗口状态栏能够正确弹出快速拾取菜单) ## 1.0.10 diff --git a/package-comment.jsonc b/package-comment.jsonc index 1128d35..6915ed4 100644 --- a/package-comment.jsonc +++ b/package-comment.jsonc @@ -4,7 +4,7 @@ "displayName": "Variable Conversion", "description": "一个强大的变量名转换插件,支持右键菜单、快捷键、状态栏等多种方式使用,支持小驼峰、大驼峰(帕斯卡)、下划线(蛇形)、中划线(连字符/脊柱式)、空格分隔、点分隔、全小写、全大写等常用命名方式(及组合)转换。 \nA powerful variable naming conversion extension. You can use it through the editer menu, shortcut keys and bottom bar. Support camel, pascal, snake, kebab(spinal), space, dot, lower, upper case, and more.", // 版本号 - "version": "1.0.11", + "version": "1.1.0", // logo "icon": "image/logo.png", "publisher": "coder-xiaomo", diff --git a/package-lock.json b/package-lock.json index 3293b51..70dc77c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "variable-conversion", - "version": "1.0.11", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "variable-conversion", - "version": "1.0.11", + "version": "1.1.0", "devDependencies": { "@types/mocha": "^10.0.6", "@types/node": "18.x", diff --git a/package.json b/package.json index d0e73f6..83e5560 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "variable-conversion", "displayName": "Variable Conversion", "description": "一个强大的变量名转换插件,支持右键菜单、快捷键、状态栏等多种方式使用,支持小驼峰、大驼峰(帕斯卡)、下划线(蛇形)、中划线(连字符/脊柱式)、空格分隔、点分隔、全小写、全大写等常用命名方式(及组合)转换。 \nA powerful variable naming conversion extension. You can use it through the editer menu, shortcut keys and bottom bar. Support camel, pascal, snake, kebab(spinal), space, dot, lower, upper case, and more.", - "version": "1.0.11", + "version": "1.1.0", "icon": "image/logo.png", "publisher": "coder-xiaomo", "engines": {