Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,19 @@ export async function activate(context: vscode.ExtensionContext) {

// 為每個 ConfigScope 建立 FileSystemWatcher(多 scope 支援)
setupWatchers(provider.configScopes, provider, context);
const watchedScopeIds = new Set<string>(provider.configScopes.map(s => s.id));

// 監聽工作區資料夾動態變更(新增/移除 folder)
context.subscriptions.push(
vscode.workspace.onDidChangeWorkspaceFolders(() => {
// 重新執行 discovery 並更新 provider 的 configScopes
provider.reinitializeScopes();
// 為新增的 scope 建立 FileSystemWatcher(避免重複建立已有的)
const newScopes = provider.configScopes.filter(s => !watchedScopeIds.has(s.id));
if (newScopes.length > 0) {
setupWatchers(newScopes, provider, context);
newScopes.forEach(s => watchedScopeIds.add(s.id));
}
})
);
}
Expand Down
Loading