Skip to content

Commit 8656796

Browse files
authored
Merge pull request #30 from RT-Thread/copilot/fix-initial-bsp-status
Fix: Remove 📌 marker from initial BSP when switching to another BSP in workspace mode
2 parents bc86a80 + ecd2d66 commit 8656796

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { initDockView } from './dock';
1515
import { setupVEnv } from './venv';
1616
import { initAPI } from './api';
1717
import { openWorkspaceProjectsWebview } from './webviews/project';
18-
import { initProjectTree } from './project/tree';
18+
import { initProjectTree, setCurrentSelectedBspItem } from './project/tree';
1919
import { DecorationProvider } from './project/fileDecorationProvider';
2020
import { getCurrentProjectInWorkspace } from './webviews/project';
2121
import { initCurrentProject } from './project/cmd';
@@ -73,6 +73,8 @@ export async function activate(context: vscode.ExtensionContext) {
7373
DecorationProvider.getInstance().markFile(vscode.Uri.file(currentProject));
7474
// 初始化当前项目到 cmd.ts 的 _currentProject 变量
7575
initCurrentProject(currentProject);
76+
// 初始化当前选中的BSP项目,以便后续切换时能正确移除标记
77+
setCurrentSelectedBspItem(currentProject);
7678
}
7779
}
7880
}

src/project/tree.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ let currentSelectedBspItem: ProjectTreeItem | null = null;
1818
// 添加树视图刷新事件发射器
1919
let _onDidChangeTreeData: vscode.EventEmitter<ProjectTreeItem | undefined> | null = null;
2020

21+
// 设置当前选中的BSP项目(用于初始化时设置)
22+
export function setCurrentSelectedBspItem(fn: string) {
23+
// Create a minimal ProjectTreeItem for tracking
24+
currentSelectedBspItem = new ProjectTreeItem(
25+
path.basename(fn),
26+
vscode.TreeItemCollapsibleState.None,
27+
'project_bsp',
28+
fn
29+
);
30+
}
31+
2132
export class ProjectTreeItem extends vscode.TreeItem {
2233
children: ProjectTreeItem[];
2334
fn: string = '';

0 commit comments

Comments
 (0)