Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
37 changes: 26 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ 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) {
// Show message and open settings when no menu items configured
vscode.window.showInformationMessage(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 可以直接打开,而不是还需要点击打开设置才打开。可以是直接打开,然后简单给一份提示,然后这份提示过一段时间后自动消失。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改。现在按 Ctrl+Shift+M 时,设置页面会直接打开,同时在状态栏显示一条提示消息(5秒后自动消失)。

更改内容:

  • 移除了需要点击的信息对话框和按钮
  • 直接调用 vscode.commands.executeCommand('workbench.action.openSettings', 'smart.menuCommands')
  • 使用 vscode.window.setStatusBarMessage() 显示临时提示(5秒后自动消失)

提交: d103bd6

'自定义菜单命令未配置,请在设置中添加自定义命令。',
'打开设置'
).then(selection => {
if (selection === '打开设置') {
vscode.commands.executeCommand('workbench.action.openSettings', 'smart.menuCommands');
}
});
} 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 +208,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