Skip to content

Commit ba51179

Browse files
committed
fix: 右键菜单调整生效位置
1 parent 02dcdbc commit ba51179

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
]
7070
},
7171
"menus": {
72-
"explorer/context": [
72+
"view/item/context": [
7373
{
7474
"command": "codeReDesign.applyThisCvb",
7575
"when": "resourceExtname == .cvb",
@@ -85,6 +85,9 @@
8585
"when": "resourceExtname == .cvb",
8686
"group": "cvb@1"
8787
}
88+
],
89+
"commandPalette": [
90+
{"command": "codeReDesign.stopOperation"}
8891
]
8992
},
9093
"configuration": {

src/siderBar.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ import { getCurrentOperationController, resetCurrentOperationController, clearC
88
export function registerCvbContextMenu(context: vscode.ExtensionContext) {
99

1010
// 注册右键菜单命令
11-
const applyCvbCommand = vscode.commands.registerCommand('codeReDesign.applyThisCvb', (uri: vscode.Uri) => {
11+
const applyCvbCommand = vscode.commands.registerCommand('codeReDesign.applyThisCvb', (cvb: CvbFile) => {
1212
// 获取文件路径
13-
const filePath = uri.fsPath;
14-
13+
const filePath = cvb.resourceUri?.fsPath || "";
1514
// 调用处理函数
1615
applyThisCvb(filePath);
1716
});
1817

1918
// 注册上传 CVB 命令
20-
const uploadCvbCommand = vscode.commands.registerCommand('codeReDesign.uploadThisCvb', async (uri: vscode.Uri) => {
21-
const filePath = uri.fsPath;
19+
const uploadCvbCommand = vscode.commands.registerCommand('codeReDesign.uploadThisCvb', async (cvb: CvbFile) => {
20+
const filePath = cvb.resourceUri?.fsPath || "";
2221
await uploadThisCvb(filePath);
2322
});
2423

2524
// 注册分析 CVB 命令
26-
const analyzeCvbCommand = vscode.commands.registerCommand('codeReDesign.analyzeThisCvb', async (uri: vscode.Uri) => {
27-
const filePath = uri.fsPath;
25+
const analyzeCvbCommand = vscode.commands.registerCommand('codeReDesign.analyzeThisCvb', async (cvb: CvbFile) => {
26+
const filePath = cvb.resourceUri?.fsPath || "";
2827
await analyzeThisCvb(filePath);
2928
});
3029

@@ -105,6 +104,11 @@ class CvbViewProvider implements vscode.TreeDataProvider<CvbFile> {
105104
});
106105
}
107106

107+
// 新增排序逻辑
108+
cvbFiles.sort((a, b) =>
109+
a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })
110+
);
111+
108112
return cvbFiles;
109113
}
110114
}
@@ -127,6 +131,8 @@ class CvbFile extends vscode.TreeItem {
127131
// 设置图标(可选)
128132
this.iconPath = vscode.ThemeIcon.File;
129133

134+
this.resourceUri = uri;
135+
130136
// 添加上下文菜单
131137
this.contextValue = 'cvbFile';
132138
}

0 commit comments

Comments
 (0)