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
34 changes: 24 additions & 10 deletions src/integrations/workspace/WorkspaceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,35 @@ class WorkspaceTracker {

this.disposables.push(watcher)

this.disposables.push(vscode.window.tabGroups.onDidChangeTabs(() => this.workspaceDidReset()))
// Listen for tab changes and call workspaceDidUpdate directly
this.disposables.push(
vscode.window.tabGroups.onDidChangeTabs(() => {
// Reset if workspace path has changed
if (this.prevWorkSpacePath !== this.cwd) {
this.workspaceDidReset()
} else {
// Otherwise just update
this.workspaceDidUpdate()
}
}),
)
}

private getOpenedTabsInfo() {
return vscode.window.tabGroups.all.flatMap((group) =>
group.tabs
.filter((tab) => tab.input instanceof vscode.TabInputText)
.map((tab) => {
const path = (tab.input as vscode.TabInputText).uri.fsPath
return {
return vscode.window.tabGroups.all.reduce(
(acc, group) => {
const groupTabs = group.tabs
.filter((tab) => tab.input instanceof vscode.TabInputText)
.map((tab) => ({
label: tab.label,
isActive: tab.isActive,
path: toRelativePath(path, this.cwd || ""),
}
}),
path: toRelativePath((tab.input as vscode.TabInputText).uri.fsPath, this.cwd || ""),
}))

groupTabs.forEach((tab) => (tab.isActive ? acc.unshift(tab) : acc.push(tab)))
return acc
},
[] as Array<{ label: string; isActive: boolean; path: string }>,
)
}

Expand Down
Loading