Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
bad03a6074 | |||
076553967c | |||
33d743afc7 | |||
8f8ae89be5 | |||
c50dfe4f70 | |||
3ff4c068f2 |
@@ -25,6 +25,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **[BREAKING!!!]** Deprecate `variable-conversion.disableFormat`, please use `variable-conversion.enabledFormats` instead. (移除 `variable-conversion.disableFormat` 配置项,请使用 `variable-conversion.enabledFormats`)
|
||||||
|
- Support enabling only partial target conversion formats. (支持仅开启部分目标转换格式)
|
||||||
|
|
||||||
## 2.0.1
|
## 2.0.1
|
||||||
|
|
||||||
### Internal
|
### Internal
|
||||||
|
17
README.md
17
README.md
@@ -5,14 +5,20 @@
|
|||||||
一个强大的变量命名及路径风格转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。<br>
|
一个强大的变量命名及路径风格转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。<br>
|
||||||
A powerful variable and path conversion extension. Supports one-key conversion & cyclic conversion. You can use it through the editer menu, shortcut keys and status bar.
|
A powerful variable and path conversion extension. Supports one-key conversion & cyclic conversion. You can use it through the editer menu, shortcut keys and status bar.
|
||||||
|
|
||||||
> **【近期更新】v2.0.1 版本 (2025-07-12)**
|
> **【近期更新】**
|
||||||
|
>
|
||||||
|
> **v2.1.0 (2025-07-14)**
|
||||||
|
>
|
||||||
|
> - 支持仅开启部分目标转换格式 (优化 VSCode 配置项)
|
||||||
|
>
|
||||||
|
> **v2.0.0 (2024-12-15)**
|
||||||
>
|
>
|
||||||
> - 支持 Windows / Unix 路径风格转换(可选中文本中的路径,然后使用 `Ctrl + Alt + /` 快捷键,或点击右键菜单、底部状态栏路径转换按钮轻松实现转换)
|
> - 支持 Windows / Unix 路径风格转换(可选中文本中的路径,然后使用 `Ctrl + Alt + /` 快捷键,或点击右键菜单、底部状态栏路径转换按钮轻松实现转换)
|
||||||
|
|
||||||
- ✅ 支持多选区 Support multi-selection
|
- ✅ 支持多选区 Support multi-selection
|
||||||
- ✅ 支持多窗口 Support subwindow
|
- ✅ 支持多窗口 Support subwindow
|
||||||
- ✅ 支持撤回 & 重做 Support undo & redo (Ctrl + Z / Ctrl + Y)
|
- ✅ 支持撤回 & 重做 Support undo & redo (Ctrl + Z / Ctrl + Y)
|
||||||
- ✅ 支持禁用部分目标转换格式 Supports disabling some target conversion formats
|
- ✅ 支持仅开启部分目标转换格式 Support enabling only partial target conversion formats
|
||||||
|
|
||||||
> 🔭 Tips for Chinese users: 如果您无法看到下文图片,请[点这里](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension/blob/main/README.md)查看
|
> 🔭 Tips for Chinese users: 如果您无法看到下文图片,请[点这里](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension/blob/main/README.md)查看
|
||||||
|
|
||||||
@@ -84,9 +90,10 @@ Or right-click on the selected text -> Convert string to...
|
|||||||
|
|
||||||
## 配置项 Configurations
|
## 配置项 Configurations
|
||||||
|
|
||||||
| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 |
|
| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 |
|
||||||
| ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | ------ |
|
| --------------------------------------- | ------------------------------------------------------------ | ------------------------------------- | -------- |
|
||||||
| `variable-conversion.disableFormat` | 定义哪些格式是禁用的<br />Define which formats are disabled. | `["lower_case", "upper_case"]` | `[]` |
|
| `variable-conversion.enabledFormats` | 配置启用的变量命名方式<br />Configuration of Enabled Variable Naming Conventions. | `{ "xxxCase.enabled": boolean, ... }` | 见配置项 |
|
||||||
|
| `variable-conversion.disablePathFormat` | 定义哪些路径风格是禁用的<br />Define which path formats are disabled. | `["windows_style", "unix_style"]` | 见配置项 |
|
||||||
|
|
||||||
## 支持的类型 Support Case
|
## 支持的类型 Support Case
|
||||||
|
|
||||||
|
136
package.json
136
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "variable-conversion",
|
"name": "variable-conversion",
|
||||||
"displayName": "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.",
|
"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": "2.0.1",
|
"version": "2.1.0",
|
||||||
"icon": "image/logo.png",
|
"icon": "image/logo.png",
|
||||||
"publisher": "coder-xiaomo",
|
"publisher": "coder-xiaomo",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -324,9 +324,141 @@
|
|||||||
"configuration": {
|
"configuration": {
|
||||||
"title": "Variable Conversion 变量转换",
|
"title": "Variable Conversion 变量转换",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"variable-conversion.enabledFormats": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Tags and options configured here will be used by the Add Tags command to add tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, json tags are added.",
|
||||||
|
"markdownDescription": "配置启用的变量命名方式\n\nConfiguration of Enabled Variable Naming Conventions.\n\n \n\n🌰 e.g. *Mike like eat ice-cream*\n\n对于这个句子,不同命名方式如以下示例:\n\nFor this sentence, different naming conventions are as follows:\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)",
|
||||||
|
"scope": "window",
|
||||||
|
"properties": {
|
||||||
|
"lowerCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全小写命名] lower case (全小写)\n 🌰e.g. mike like eat ice-cream"
|
||||||
|
},
|
||||||
|
"snakeCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全小写命名] snake case (下划线)\n 🌰e.g. mike_like_eat_ice_cream"
|
||||||
|
},
|
||||||
|
"kebabCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全小写命名] kebab case (连字符)\n 🌰e.g. mike-like-eat-ice-cream"
|
||||||
|
},
|
||||||
|
"spaceCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全小写命名] space case (空格)\n 🌰e.g. mike like eat ice cream"
|
||||||
|
},
|
||||||
|
"dotCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全小写命名] dot case (点)\n 🌰e.g. mike.like.eat.ice.cream"
|
||||||
|
},
|
||||||
|
"upperCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全大写命名] upper case (全大写)\n 🌰e.g. MIKE LIKE EAT ICE-CREAM"
|
||||||
|
},
|
||||||
|
"snakeUpperCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全大写命名] snake upper case (下划线)\n 🌰e.g. MIKE_LIKE_EAT_ICE_CREAM"
|
||||||
|
},
|
||||||
|
"kebabUpperCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全大写命名] kebab upper case (连字符)\n 🌰e.g. MIKE-LIKE-EAT-ICE-CREAM"
|
||||||
|
},
|
||||||
|
"spaceUpperCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全大写命名] space upper case (空格)\n 🌰e.g. MIKE LIKE EAT ICE CREAM"
|
||||||
|
},
|
||||||
|
"dotUpperCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[全大写命名] dot upper case (点)\n 🌰e.g. MIKE.LIKE.EAT.ICE.CREAM"
|
||||||
|
},
|
||||||
|
"pascalCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[大驼峰命名] pascal case (大驼峰)\n 🌰e.g. MikeLikeEatIceCream"
|
||||||
|
},
|
||||||
|
"snakePascalCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[大驼峰命名] snake pascal case (下划线)\n 🌰e.g. Mike_Like_Eat_Ice_Cream"
|
||||||
|
},
|
||||||
|
"kebabPascalCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[大驼峰命名] kebab pascal case (连字符)\n 🌰e.g. Mike-Like-Eat-Ice-Cream"
|
||||||
|
},
|
||||||
|
"spacePascalCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[大驼峰命名] space pascal case (空格)\n 🌰e.g. Mike Like Eat Ice Cream"
|
||||||
|
},
|
||||||
|
"dotPascalCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[大驼峰命名] dot pascal case (点)\n 🌰e.g. Mike.Like.Eat.Ice.Cream"
|
||||||
|
},
|
||||||
|
"camelCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[小驼峰命名] camel case (小驼峰)\n 🌰e.g. mikeLikeEatIceCream"
|
||||||
|
},
|
||||||
|
"snakeCamelCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[小驼峰命名] snake camel case (下划线)\n 🌰e.g. mike_Like_Eat_Ice_Cream"
|
||||||
|
},
|
||||||
|
"kebabCamelCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[小驼峰命名] kebab camel case (连字符)\n 🌰e.g. mike-Like-Eat-Ice-Cream"
|
||||||
|
},
|
||||||
|
"spaceCamelCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[小驼峰命名] space camel case (空格)\n 🌰e.g. mike Like Eat Ice Cream"
|
||||||
|
},
|
||||||
|
"dotCamelCase.enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "[小驼峰命名] dot camel case (点)\n 🌰e.g. mike.Like.Eat.Ice.Cream"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"default": {
|
||||||
|
"lowerCase.enabled": true,
|
||||||
|
"snakeCase.enabled": true,
|
||||||
|
"kebabCase.enabled": true,
|
||||||
|
"spaceCase.enabled": true,
|
||||||
|
"dotCase.enabled": false,
|
||||||
|
"upperCase.enabled": true,
|
||||||
|
"snakeUpperCase.enabled": true,
|
||||||
|
"kebabUpperCase.enabled": false,
|
||||||
|
"spaceUpperCase.enabled": true,
|
||||||
|
"dotUpperCase.enabled": false,
|
||||||
|
"pascalCase.enabled": true,
|
||||||
|
"snakePascalCase.enabled": false,
|
||||||
|
"kebabPascalCase.enabled": false,
|
||||||
|
"spacePascalCase.enabled": false,
|
||||||
|
"dotPascalCase.enabled": false,
|
||||||
|
"camelCase.enabled": true,
|
||||||
|
"snakeCamelCase.enabled": false,
|
||||||
|
"kebabCamelCase.enabled": false,
|
||||||
|
"spaceCamelCase.enabled": false,
|
||||||
|
"dotCamelCase.enabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"variable-conversion.disableFormat": {
|
"variable-conversion.disableFormat": {
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"markdownDescription": "定义哪些变量命名方式是禁用的\n\nDefine which variable 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)",
|
"markdownDescription": "定义哪些变量命名方式是禁用的\n\nDefine which variable 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)",
|
||||||
|
"markdownDeprecationMessage": "**Deprecated**: Please use `#variable-conversion.enabledFormats#` instead.\n\n**已弃用**,请使用 `#variable-conversion.enabledFormats#`。",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -418,4 +550,4 @@
|
|||||||
"eslint": "^9.25.1",
|
"eslint": "^9.25.1",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ function lazyConvert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户配置
|
// 获取用户配置
|
||||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||||
|
|
||||||
const textList = userSelection.currentSelectionsText;
|
const textList = userSelection.currentSelectionsText;
|
||||||
// vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
|
// vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
|
||||||
@@ -75,7 +75,7 @@ function lazyConvert() {
|
|||||||
for (const cyclicConvertCase of cyclicConvertCaseOrder) {
|
for (const cyclicConvertCase of cyclicConvertCaseOrder) {
|
||||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||||
// 跳过禁用的目标格式
|
// 跳过禁用的目标格式
|
||||||
if (disableFormatList.includes(cyclicConvertCase.settingsKey)) {
|
if (enabledFormats[cyclicConvertCase.settingsKey] === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -278,114 +278,142 @@ const keyword = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface Command {
|
||||||
|
command: string;
|
||||||
|
targetCase: SupportVariableCase;
|
||||||
|
settingsKey: string;
|
||||||
|
// variable-conversion.enabledFormats 中的配置项
|
||||||
|
enableSettingsKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接管的变量转换命令
|
* 接管的变量转换命令
|
||||||
*/
|
*/
|
||||||
export const commands: Array<{ command: string; targetCase: SupportVariableCase; settingsKey: string }> = [
|
export const commands: Array<Command> = [
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toCamelCase',
|
command: 'variable-conversion.toCamelCase',
|
||||||
targetCase: SupportVariableCase.CAMEL_CASE,
|
targetCase: SupportVariableCase.CAMEL_CASE,
|
||||||
settingsKey: 'camel_case'
|
settingsKey: 'camel_case',
|
||||||
|
enableSettingsKey: 'camelCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toPascalCase',
|
command: 'variable-conversion.toPascalCase',
|
||||||
targetCase: SupportVariableCase.PASCAL_CASE,
|
targetCase: SupportVariableCase.PASCAL_CASE,
|
||||||
settingsKey: 'pascal_case'
|
settingsKey: 'pascal_case',
|
||||||
|
enableSettingsKey: 'pascalCase.enabled',
|
||||||
},
|
},
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSnakeCase',
|
command: 'variable-conversion.toSnakeCase',
|
||||||
targetCase: SupportVariableCase.SNAKE_CASE,
|
targetCase: SupportVariableCase.SNAKE_CASE,
|
||||||
settingsKey: 'snake_case'
|
settingsKey: 'snake_case',
|
||||||
|
enableSettingsKey: 'snakeCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSnakeUpperCase',
|
command: 'variable-conversion.toSnakeUpperCase',
|
||||||
targetCase: SupportVariableCase.SNAKE_UPPER_CASE,
|
targetCase: SupportVariableCase.SNAKE_UPPER_CASE,
|
||||||
settingsKey: 'snake_upper_case'
|
settingsKey: 'snake_upper_case',
|
||||||
|
enableSettingsKey: 'snakeUpperCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSnakePascalCase',
|
command: 'variable-conversion.toSnakePascalCase',
|
||||||
targetCase: SupportVariableCase.SNAKE_PASCAL_CASE,
|
targetCase: SupportVariableCase.SNAKE_PASCAL_CASE,
|
||||||
settingsKey: 'snake_pascal_case'
|
settingsKey: 'snake_pascal_case',
|
||||||
|
enableSettingsKey: 'snakePascalCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSnakeCamelCase',
|
command: 'variable-conversion.toSnakeCamelCase',
|
||||||
targetCase: SupportVariableCase.SNAKE_CAMEL_CASE,
|
targetCase: SupportVariableCase.SNAKE_CAMEL_CASE,
|
||||||
settingsKey: 'snake_camel_case'
|
settingsKey: 'snake_camel_case',
|
||||||
|
enableSettingsKey: 'snakeCamelCase.enabled',
|
||||||
},
|
},
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toKebabCase',
|
command: 'variable-conversion.toKebabCase',
|
||||||
targetCase: SupportVariableCase.KEBAB_CASE,
|
targetCase: SupportVariableCase.KEBAB_CASE,
|
||||||
settingsKey: 'kebab_case'
|
settingsKey: 'kebab_case',
|
||||||
|
enableSettingsKey: 'kebabCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toKebabUpperCase',
|
command: 'variable-conversion.toKebabUpperCase',
|
||||||
targetCase: SupportVariableCase.KEBAB_UPPER_CASE,
|
targetCase: SupportVariableCase.KEBAB_UPPER_CASE,
|
||||||
settingsKey: 'kebab_upper_case'
|
settingsKey: 'kebab_upper_case',
|
||||||
|
enableSettingsKey: 'kebabUpperCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toKebabPascalCase',
|
command: 'variable-conversion.toKebabPascalCase',
|
||||||
targetCase: SupportVariableCase.KEBAB_PASCAL_CASE,
|
targetCase: SupportVariableCase.KEBAB_PASCAL_CASE,
|
||||||
settingsKey: 'kebab_pascal_case'
|
settingsKey: 'kebab_pascal_case',
|
||||||
|
enableSettingsKey: 'kebabPascalCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toKebabCamelCase',
|
command: 'variable-conversion.toKebabCamelCase',
|
||||||
targetCase: SupportVariableCase.KEBAB_CAMEL_CASE,
|
targetCase: SupportVariableCase.KEBAB_CAMEL_CASE,
|
||||||
settingsKey: 'kebab_camel_case'
|
settingsKey: 'kebab_camel_case',
|
||||||
|
enableSettingsKey: 'kebabCamelCase.enabled',
|
||||||
},
|
},
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSpaceCase',
|
command: 'variable-conversion.toSpaceCase',
|
||||||
targetCase: SupportVariableCase.SPACE_CASE,
|
targetCase: SupportVariableCase.SPACE_CASE,
|
||||||
settingsKey: 'space_case'
|
settingsKey: 'space_case',
|
||||||
|
enableSettingsKey: 'spaceCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSpaceUpperCase',
|
command: 'variable-conversion.toSpaceUpperCase',
|
||||||
targetCase: SupportVariableCase.SPACE_UPPER_CASE,
|
targetCase: SupportVariableCase.SPACE_UPPER_CASE,
|
||||||
settingsKey: 'space_upper_case'
|
settingsKey: 'space_upper_case',
|
||||||
|
enableSettingsKey: 'spaceUpperCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSpacePascalCase',
|
command: 'variable-conversion.toSpacePascalCase',
|
||||||
targetCase: SupportVariableCase.SPACE_PASCAL_CASE,
|
targetCase: SupportVariableCase.SPACE_PASCAL_CASE,
|
||||||
settingsKey: 'space_pascal_case'
|
settingsKey: 'space_pascal_case',
|
||||||
|
enableSettingsKey: 'spacePascalCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toSpaceCamelCase',
|
command: 'variable-conversion.toSpaceCamelCase',
|
||||||
targetCase: SupportVariableCase.SPACE_CAMEL_CASE,
|
targetCase: SupportVariableCase.SPACE_CAMEL_CASE,
|
||||||
settingsKey: 'space_camel_case'
|
settingsKey: 'space_camel_case',
|
||||||
|
enableSettingsKey: 'spaceCamelCase.enabled',
|
||||||
},
|
},
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toDotCase',
|
command: 'variable-conversion.toDotCase',
|
||||||
targetCase: SupportVariableCase.DOT_CASE,
|
targetCase: SupportVariableCase.DOT_CASE,
|
||||||
settingsKey: 'dot_case'
|
settingsKey: 'dot_case',
|
||||||
|
enableSettingsKey: 'dotCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toDotUpperCase',
|
command: 'variable-conversion.toDotUpperCase',
|
||||||
targetCase: SupportVariableCase.DOT_UPPER_CASE,
|
targetCase: SupportVariableCase.DOT_UPPER_CASE,
|
||||||
settingsKey: 'dot_upper_case'
|
settingsKey: 'dot_upper_case',
|
||||||
|
enableSettingsKey: 'dotUpperCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toDotPascalCase',
|
command: 'variable-conversion.toDotPascalCase',
|
||||||
targetCase: SupportVariableCase.DOT_PASCAL_CASE,
|
targetCase: SupportVariableCase.DOT_PASCAL_CASE,
|
||||||
settingsKey: 'dot_pascal_case'
|
settingsKey: 'dot_pascal_case',
|
||||||
|
enableSettingsKey: 'dotPascalCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toDotCamelCase',
|
command: 'variable-conversion.toDotCamelCase',
|
||||||
targetCase: SupportVariableCase.DOT_CAMEL_CASE,
|
targetCase: SupportVariableCase.DOT_CAMEL_CASE,
|
||||||
settingsKey: 'dot_camel_case'
|
settingsKey: 'dot_camel_case',
|
||||||
|
enableSettingsKey: 'dotCamelCase.enabled',
|
||||||
},
|
},
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toLowerCase',
|
command: 'variable-conversion.toLowerCase',
|
||||||
targetCase: SupportVariableCase.LOWER_CASE,
|
targetCase: SupportVariableCase.LOWER_CASE,
|
||||||
settingsKey: 'lower_case'
|
settingsKey: 'lower_case',
|
||||||
|
enableSettingsKey: 'lowerCase.enabled',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'variable-conversion.toUpperCase',
|
command: 'variable-conversion.toUpperCase',
|
||||||
targetCase: SupportVariableCase.UPPER_CASE,
|
targetCase: SupportVariableCase.UPPER_CASE,
|
||||||
settingsKey: 'upper_case'
|
settingsKey: 'upper_case',
|
||||||
|
enableSettingsKey: 'upperCase.enabled',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -64,12 +64,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||||
// 获取用户配置
|
// 获取用户配置
|
||||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||||
const disablePathFormatList = getUserConfigurations<Array<string>>('disablePathFormat') || [];
|
const disablePathFormatList = getUserConfigurations<Array<string>>('disablePathFormat') || [];
|
||||||
// 更新右键菜单每一项是否展示
|
// 更新右键菜单每一项是否展示
|
||||||
// 变量转换右键菜单visible 2024.07.29
|
// 变量转换右键菜单visible 2024.07.29
|
||||||
for (const { settingsKey } of variableCommands) {
|
for (const { settingsKey, enableSettingsKey } of variableCommands) {
|
||||||
vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey));
|
vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, enabledFormats[enableSettingsKey] === false);
|
||||||
}
|
}
|
||||||
// 路径转换右键菜单visible 2024.12.14
|
// 路径转换右键菜单visible 2024.12.14
|
||||||
for (const { settingsKey } of pathCommands) {
|
for (const { settingsKey } of pathCommands) {
|
||||||
|
@@ -98,17 +98,17 @@ export function handleQuickPick() {
|
|||||||
|
|
||||||
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
|
||||||
// 获取用户配置
|
// 获取用户配置
|
||||||
const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
|
||||||
// 排除禁用的选项
|
// 排除禁用的选项
|
||||||
const enabledQuickPickSupportCases = [];
|
const enabledQuickPickSupportCases = [];
|
||||||
for (const quickPick of quickPickSupportCases) {
|
for (const quickPick of quickPickSupportCases) {
|
||||||
if (disableFormatList.includes(quickPick.settingsKey)) {
|
if (enabledFormats[quickPick.settingsKey] === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
enabledQuickPickSupportCases.push(quickPick);
|
enabledQuickPickSupportCases.push(quickPick);
|
||||||
}
|
}
|
||||||
if (enabledQuickPickSupportCases.length === 0) {
|
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.');
|
vscode.window.showInformationMessage('所有格式都已被配置为禁用,请修改配置 `variable-conversion.enabledFormats` 后重试\nAll formats have been configured to disable. Modify the `variable-conversion.enabledFormats` configuration and try again.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user