feat: 支持展示当前配置的格式顺序信息弹窗
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -12,6 +12,7 @@
|
|||||||
// Code Spell Checker 插件
|
// Code Spell Checker 插件
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"coder-xiaomo",
|
"coder-xiaomo",
|
||||||
"Gitee"
|
"Gitee",
|
||||||
|
"unconfigured"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Add new configuration `variable-conversion.formatOrder` to customize the display order of variable naming conventions. (新增 `variable-conversion.formatOrder` 配置项,用于自定义变量命名方式的显示顺序)
|
- 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
|
### Improved
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,11 @@
|
|||||||
},
|
},
|
||||||
"when": "editorTextFocus"
|
"when": "editorTextFocus"
|
||||||
},
|
},
|
||||||
|
// 展示当前配置的转换格式顺序对话框
|
||||||
|
{
|
||||||
|
"command": "variable-conversion.showConvertCaseOrderDialog",
|
||||||
|
"key": "ctrl+alt+\\"
|
||||||
|
},
|
||||||
// ↓ 路径转换快捷键
|
// ↓ 路径转换快捷键
|
||||||
{
|
{
|
||||||
"command": "variable-conversion.convertPath",
|
"command": "variable-conversion.convertPath",
|
||||||
@@ -686,7 +691,7 @@
|
|||||||
},
|
},
|
||||||
"variable-conversion.formatOrder": {
|
"variable-conversion.formatOrder": {
|
||||||
"type": "array",
|
"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",
|
"scope": "window",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -53,6 +53,10 @@
|
|||||||
},
|
},
|
||||||
"when": "editorTextFocus"
|
"when": "editorTextFocus"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "variable-conversion.showConvertCaseOrderDialog",
|
||||||
|
"key": "ctrl+alt+\\"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "variable-conversion.convertPath",
|
"command": "variable-conversion.convertPath",
|
||||||
"key": "shift+alt+/",
|
"key": "shift+alt+/",
|
||||||
@@ -457,7 +461,7 @@
|
|||||||
},
|
},
|
||||||
"variable-conversion.formatOrder": {
|
"variable-conversion.formatOrder": {
|
||||||
"type": "array",
|
"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",
|
"scope": "window",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
76
src/core/variable-convert/show-convert-case-order-dialog.ts
Normal file
76
src/core/variable-convert/show-convert-case-order-dialog.ts
Normal 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 });
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ import handleEditorReplaceVariable from './handler/variable-convert/editor-subme
|
|||||||
import { handleQuickPick as handleQuickPickVariable } from './handler/variable-convert/quick-pick-handler';
|
import { handleQuickPick as handleQuickPickVariable } from './handler/variable-convert/quick-pick-handler';
|
||||||
import { commands as variableCommands } from './core/variable-convert/types/SupportVariableCaseType';
|
import { commands as variableCommands } from './core/variable-convert/types/SupportVariableCaseType';
|
||||||
import * as CyclicConversionVariable from './core/variable-convert/cyclic-conversion';
|
import * as CyclicConversionVariable from './core/variable-convert/cyclic-conversion';
|
||||||
|
import { showConvertCaseOrderDialog } from './core/variable-convert/show-convert-case-order-dialog';
|
||||||
|
|
||||||
// Path Convert
|
// Path Convert
|
||||||
import handleEditorReplacePath from './handler/path-convert/editor-submenu-handler';
|
import handleEditorReplacePath from './handler/path-convert/editor-submenu-handler';
|
||||||
@@ -156,6 +157,10 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
});
|
});
|
||||||
context.subscriptions.push(loopConvertCaseNextDisposable);
|
context.subscriptions.push(loopConvertCaseNextDisposable);
|
||||||
|
|
||||||
|
// 注册显示格式顺序信息的命令
|
||||||
|
let showConvertCaseOrderDialogDisposable = vscode.commands.registerCommand('variable-conversion.showConvertCaseOrderDialog', showConvertCaseOrderDialog);
|
||||||
|
context.subscriptions.push(showConvertCaseOrderDialogDisposable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路径转换
|
* 路径转换
|
||||||
|
|||||||
Reference in New Issue
Block a user