Skip to content

Commit f06ba00

Browse files
committed
fix: use tabGroups API to close preview panels on env switch
1 parent b89c472 commit f06ba00

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/commands/previewAsset.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,18 @@ function registerPreview(context: vscode.ExtensionContext) {
121121

122122
/**
123123
* Closes all open preview panels when the active environment switches.
124-
* Panels show assets from the old environment and are no longer valid.
124+
* Uses the tab groups API so it works regardless of the openPanels tracking state.
125125
*/
126126
export function resetAllPreviewPanels(): void {
127-
for (const panel of openPanels.values()) {
128-
panel.dispose();
127+
for (const tabGroup of vscode.window.tabGroups.all) {
128+
for (const tab of tabGroup.tabs) {
129+
if (
130+
tab.input instanceof vscode.TabInputWebview &&
131+
tab.input.viewType === "cloudinaryAssetPreview"
132+
) {
133+
vscode.window.tabGroups.close(tab);
134+
}
135+
}
129136
}
130137
}
131138

0 commit comments

Comments
 (0)