Skip to content

Commit ea202da

Browse files
CopilotBernardXiong
andcommitted
Fix: Always register openMenu command and improve settings UI
- Register extension.openMenu command regardless of menu items existence - Show helpful message and open settings when menu is empty - Improve package.json configuration with descriptions and examples - Add minimum value validation for parallelBuidNumber Co-authored-by: BernardXiong <[email protected]>
1 parent 00dad49 commit ea202da

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,27 @@
159159
},
160160
"configuration": {
161161
"type": "object",
162-
"title": "Custom Commands(menu)",
162+
"title": "RT-Thread Smart",
163163
"properties": {
164164
"smart.menuCommands": {
165165
"type": "array",
166166
"items": {
167167
"type": "string"
168168
},
169-
"default": []
169+
"default": [],
170+
"description": "自定义构建菜单命令列表,使用 Ctrl+Shift+M 快捷键打开菜单。",
171+
"markdownDescription": "自定义构建菜单命令列表,使用 `Ctrl+Shift+M` 快捷键打开菜单。\n\n**示例:**\n```json\n[\n \"scons -c\",\n \"scons --dist\",\n \"scons --target=mdk5\"\n]\n```",
172+
"scope": "resource",
173+
"order": 0
170174
},
171175
"smart.parallelBuidNumber": {
172176
"type": "number",
173-
"default": 1
177+
"default": 1,
178+
"minimum": 1,
179+
"description": "并行编译使用的 CPU 核心数(默认为 1)。设置大于 1 的值可以加快编译速度。",
180+
"markdownDescription": "并行编译使用的 CPU 核心数(默认为 1)。\n\n设置大于 1 的值可以加快编译速度,例如:\n- `1`: 单核编译\n- `4`: 使用 4 个核心并行编译\n- `8`: 使用 8 个核心并行编译",
181+
"scope": "resource",
182+
"order": 1
174183
}
175184
}
176185
},

src/extension.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,32 @@ function setupStatusBarItems(context: vscode.ExtensionContext) {
174174
});
175175

176176
let menuItems = getMenuItems();
177+
178+
// Always register the command, regardless of menu items
179+
let disposable = vscode.commands.registerCommand('extension.openMenu', () => {
180+
const items = getMenuItems();
181+
if (!items || items.length === 0) {
182+
// Show message and open settings when no menu items configured
183+
vscode.window.showInformationMessage(
184+
'自定义菜单命令未配置,请在设置中添加自定义命令。',
185+
'打开设置'
186+
).then(selection => {
187+
if (selection === '打开设置') {
188+
vscode.commands.executeCommand('workbench.action.openSettings', 'smart.menuCommands');
189+
}
190+
});
191+
} else {
192+
vscode.window.showQuickPick(items).then(selectedItem => {
193+
if (selectedItem) {
194+
executeCommand(selectedItem);
195+
}
196+
});
197+
}
198+
});
199+
200+
context.subscriptions.push(disposable);
201+
202+
// Only show status bar item if menu items exist
177203
if (menuItems && menuItems.length > 0) {
178204
const statusItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
179205
statusItem.text = '$(menu) 自定义构建...';
@@ -182,17 +208,6 @@ function setupStatusBarItems(context: vscode.ExtensionContext) {
182208
statusItem.show();
183209

184210
context.subscriptions.push(statusItem);
185-
186-
let disposable = vscode.commands.registerCommand('extension.openMenu', () => {
187-
const items = getMenuItems();
188-
vscode.window.showQuickPick(items).then(selectedItem => {
189-
if (selectedItem) {
190-
executeCommand(selectedItem);
191-
}
192-
});
193-
});
194-
195-
context.subscriptions.push(disposable);
196211
}
197212
}
198213

0 commit comments

Comments
 (0)