Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
31 changes: 20 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) 自定义构建...';
Expand All @@ -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);
}
}

Expand Down