1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

feat: 支持展示当前配置的格式顺序信息弹窗

This commit is contained in:
2025-12-05 11:06:33 +08:00
parent d83481c6a4
commit 2d84be6976
6 changed files with 97 additions and 3 deletions

View File

@@ -12,6 +12,7 @@
// Code Spell Checker 插件
"cSpell.words": [
"coder-xiaomo",
"Gitee"
"Gitee",
"unconfigured"
],
}

View File

@@ -30,6 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add new configuration `variable-conversion.formatOrder` to customize the display order of variable naming conventions. (新增 `variable-conversion.formatOrder` 配置项,用于自定义变量命名方式的显示顺序)
- Add new command `variable-conversion.showConvertCaseOrderDialog` to display current format order configuration. (新增 `variable-conversion.showConvertCaseOrderDialog` 命令,用于显示当前配置的格式顺序信息)
- Add clickable link in formatOrder configuration description to trigger info display. (在 formatOrder 配置项描述中添加了点击触发命令的超链接)
- Add shortcut key `Ctrl + Alt + \` to trigger format order info display dialog. (新增快捷键 `Ctrl + Alt + \` 用于触发显示格式顺序弹窗)
### Improved

View File

@@ -64,6 +64,11 @@
},
"when": "editorTextFocus"
},
// 展示当前配置的转换格式顺序对话框
{
"command": "variable-conversion.showConvertCaseOrderDialog",
"key": "ctrl+alt+\\"
},
// ↓ 路径转换快捷键
{
"command": "variable-conversion.convertPath",
@@ -686,7 +691,7 @@
},
"variable-conversion.formatOrder": {
"type": "array",
"markdownDescription": "配置变量命名方式的显示顺序\n\nConfigure the display order of variable naming conventions.\n\n该配置中的格式名称必须与enabledFormats中的保持一致。如果某个格式在enabledFormats中被禁用则即使在formatOrder中配置也不会显示。\n\nFormat names in this configuration must be consistent with those in enabledFormats. If a format is disabled in enabledFormats, it will not be displayed even if configured in formatOrder.\n\n \n\n🌰 e.g. `[\"camel_case\", \"snake_case\", \"pascal_case\"]`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)",
"markdownDescription": "配置变量命名方式的显示顺序\n\nConfigure the display order of variable naming conventions.\n\n该配置中的格式名称必须与enabledFormats中的保持一致。如果某个格式在enabledFormats中被禁用则即使在formatOrder中配置也不会显示。\n\nFormat names in this configuration must be consistent with those in enabledFormats. If a format is disabled in enabledFormats, it will not be displayed even if configured in formatOrder.\n\n \n\n🌰 e.g. `[\"camel_case\", \"snake_case\", \"pascal_case\"]`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n[查看当前配置顺序](command:variable-conversion.showConvertCaseOrderDialog)",
"scope": "window",
"items": {
"type": "string",

View File

@@ -53,6 +53,10 @@
},
"when": "editorTextFocus"
},
{
"command": "variable-conversion.showConvertCaseOrderDialog",
"key": "ctrl+alt+\\"
},
{
"command": "variable-conversion.convertPath",
"key": "shift+alt+/",
@@ -457,7 +461,7 @@
},
"variable-conversion.formatOrder": {
"type": "array",
"markdownDescription": "配置变量命名方式的显示顺序\n\nConfigure the display order of variable naming conventions.\n\n该配置中的格式名称必须与enabledFormats中的保持一致。如果某个格式在enabledFormats中被禁用则即使在formatOrder中配置也不会显示。\n\nFormat names in this configuration must be consistent with those in enabledFormats. If a format is disabled in enabledFormats, it will not be displayed even if configured in formatOrder.\n\n \n\n🌰 e.g. `[\"camel_case\", \"snake_case\", \"pascal_case\"]`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)",
"markdownDescription": "配置变量命名方式的显示顺序\n\nConfigure the display order of variable naming conventions.\n\n该配置中的格式名称必须与enabledFormats中的保持一致。如果某个格式在enabledFormats中被禁用则即使在formatOrder中配置也不会显示。\n\nFormat names in this configuration must be consistent with those in enabledFormats. If a format is disabled in enabledFormats, it will not be displayed even if configured in formatOrder.\n\n \n\n🌰 e.g. `[\"camel_case\", \"snake_case\", \"pascal_case\"]`\n\n[在 settings.json 中编辑 (Edit in settings.json)](command:workbench.action.openSettingsJson)\n\n[查看当前配置顺序](command:variable-conversion.showConvertCaseOrderDialog)",
"scope": "window",
"items": {
"type": "string",

View File

@@ -0,0 +1,76 @@
import * as vscode from 'vscode';
import { cyclicConvertCaseOrder, quickPickSupportCases, commands } from './types/SupportVariableCaseType';
import { getUserConfigurations } from '../../utils/user-configuration';
/**
* 显示当前配置的格式顺序信息
*/
export function showConvertCaseOrderDialog() {
// 获取用户配置的格式顺序
const formatOrder = getUserConfigurations<string[]>('formatOrder') || [];
// 获取启用的格式
const enabledFormats = getUserConfigurations<Record<string, boolean>>('enabledFormats') || {};
// 创建格式名称映射
const formatNameMap: Record<string, string> = {};
quickPickSupportCases.forEach(item => {
formatNameMap[item.settingsKey] = item.name;
});
// 创建settingsKey到enableSettingsKey的映射
const settingsKeyToEnableKeyMap: Record<string, string> = {};
commands.forEach(item => {
settingsKeyToEnableKeyMap[item.settingsKey] = item.enableSettingsKey;
});
// 构建显示内容
let message = '当前配置的变量命名格式顺序:\n\n';
// 先显示用户配置的顺序
if (formatOrder.length > 0) {
message += '用户自定义顺序:\n';
formatOrder.forEach((format, index) => {
const isEnabled = enabledFormats[format] !== false;
const status = isEnabled ? '✅' : '❌';
message += `${index + 1}. ${formatNameMap[format] || format} (${format}) ${status}\n`;
});
} else {
message += '未设置自定义顺序,使用默认顺序\n\n';
}
// 显示未配置但已启用的格式
const unconfiguredEnabledFormats = cyclicConvertCaseOrder
.filter(item => {
const enableKey = settingsKeyToEnableKeyMap[item.settingsKey];
const isEnabled = enableKey ? enabledFormats[enableKey] !== false : true;
return isEnabled && !formatOrder.includes(item.settingsKey);
})
.map(item => item.settingsKey);
if (unconfiguredEnabledFormats.length > 0) {
message += '\n未配置但已启用的格式默认顺序\n';
unconfiguredEnabledFormats.forEach((format, index) => {
message += `${formatOrder.length + index + 1}. ${formatNameMap[format] || format} (${format}) ✅\n`;
});
}
// 显示未启用的格式
const disabledFormats = cyclicConvertCaseOrder
.filter(item => {
const enableKey = settingsKeyToEnableKeyMap[item.settingsKey];
return enableKey ? enabledFormats[enableKey] === false : false;
})
.map(item => item.settingsKey);
if (disabledFormats.length > 0) {
message += '\n未启用的格式\n';
disabledFormats.forEach(format => {
message += `- ${formatNameMap[format] || format} (${format}) ❌\n`;
});
}
message += '\n提示未启用的格式即使在顺序中配置也不会显示在转换选项中';
// 显示信息弹窗
vscode.window.showInformationMessage<vscode.MessageItem>('格式顺序配置信息', { modal: true, detail: message });
}

View File

@@ -17,6 +17,7 @@ import handleEditorReplaceVariable from './handler/variable-convert/editor-subme
import { handleQuickPick as handleQuickPickVariable } from './handler/variable-convert/quick-pick-handler';
import { commands as variableCommands } from './core/variable-convert/types/SupportVariableCaseType';
import * as CyclicConversionVariable from './core/variable-convert/cyclic-conversion';
import { showConvertCaseOrderDialog } from './core/variable-convert/show-convert-case-order-dialog';
// Path Convert
import handleEditorReplacePath from './handler/path-convert/editor-submenu-handler';
@@ -156,6 +157,10 @@ export function activate(context: vscode.ExtensionContext) {
});
context.subscriptions.push(loopConvertCaseNextDisposable);
// 注册显示格式顺序信息的命令
let showConvertCaseOrderDialogDisposable = vscode.commands.registerCommand('variable-conversion.showConvertCaseOrderDialog', showConvertCaseOrderDialog);
context.subscriptions.push(showConvertCaseOrderDialogDisposable);
/**
* 路径转换