diff --git a/package.json b/package.json index 91bcba0..099eb82 100644 --- a/package.json +++ b/package.json @@ -159,18 +159,27 @@ }, "configuration": { "type": "object", - "title": "Custom Commands(menu)", + "title": "RT-Thread Smart", "properties": { "smart.menuCommands": { "type": "array", "items": { "type": "string" }, - "default": [] + "default": [], + "description": "自定义构建菜单命令列表,使用 Ctrl+Shift+M 快捷键打开菜单。", + "markdownDescription": "自定义构建菜单命令列表,使用 `Ctrl+Shift+M` 快捷键打开菜单。\n\n**示例:**\n```json\n[\n \"scons -c\",\n \"scons --dist\",\n \"scons --target=mdk5\"\n]\n```", + "scope": "resource", + "order": 0 }, "smart.parallelBuidNumber": { "type": "number", - "default": 1 + "default": 1, + "minimum": 1, + "description": "并行编译使用的 CPU 核心数(默认为 1)。设置大于 1 的值可以加快编译速度。", + "markdownDescription": "并行编译使用的 CPU 核心数(默认为 1)。\n\n设置大于 1 的值可以加快编译速度,例如:\n- `1`: 单核编译\n- `4`: 使用 4 个核心并行编译\n- `8`: 使用 8 个核心并行编译", + "scope": "resource", + "order": 1 } } }, diff --git a/src/extension.ts b/src/extension.ts index f88a5ae..e8236fb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -174,6 +174,26 @@ function setupStatusBarItems(context: vscode.ExtensionContext) { }); let menuItems = getMenuItems(); + + // Always register the command, regardless of menu items + let disposable = vscode.commands.registerCommand('extension.openMenu', () => { + const items = getMenuItems(); + if (!items || items.length === 0) { + // Directly open settings and show a temporary notification + vscode.commands.executeCommand('workbench.action.openSettings', 'smart.menuCommands'); + vscode.window.setStatusBarMessage('$(info) 自定义菜单命令未配置,请添加自定义命令', 5000); + } else { + vscode.window.showQuickPick(items).then(selectedItem => { + if (selectedItem) { + executeCommand(selectedItem); + } + }); + } + }); + + context.subscriptions.push(disposable); + + // Only show status bar item if menu items exist if (menuItems && menuItems.length > 0) { const statusItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); statusItem.text = '$(menu) 自定义构建...'; @@ -182,17 +202,6 @@ function setupStatusBarItems(context: vscode.ExtensionContext) { statusItem.show(); context.subscriptions.push(statusItem); - - let disposable = vscode.commands.registerCommand('extension.openMenu', () => { - const items = getMenuItems(); - vscode.window.showQuickPick(items).then(selectedItem => { - if (selectedItem) { - executeCommand(selectedItem); - } - }); - }); - - context.subscriptions.push(disposable); } }