右键菜单支持过滤用户配置的禁用格式 (disableFormat)
This commit is contained in:
parent
68ffcc49f7
commit
4c302ddbb2
@ -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"
|
||||
}
|
||||
|
20
package.json
20
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"
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user