Skip to content

Commit f6bb233

Browse files
committed
Close serialized webview when another view already exists
When deserializing a webview, it could happen that a view was already manually opened by the user before the webview was deserialized. This would result in duplicate webview tabs, which is not supported by the manager. This will close the webview that is being deserialized and focus on the existing view. This should ensure that we never have duplicate loaded webview tabs. There could still be duplicate webview tabs if there are non-deserialized tabs, but once it is opened it should be closed automatically.
1 parent 386e9bb commit f6bb233

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

extensions/ql-vscode/src/remote-queries/variant-analysis-view-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface VariantAnalysisViewManager<
1313
> {
1414
registerView(view: T): void;
1515
unregisterView(view: T): void;
16+
getView(variantAnalysisId: number): T | undefined;
1617

1718
getVariantAnalysis(
1819
variantAnalysisId: number,

extensions/ql-vscode/src/remote-queries/variant-analysis-view-serializer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
3838

3939
const manager = await this.waitForExtensionFullyLoaded();
4040

41+
const existingView = manager.getView(
42+
variantAnalysisState.variantAnalysisId,
43+
);
44+
if (existingView) {
45+
await existingView.openView();
46+
webviewPanel.dispose();
47+
return;
48+
}
49+
4150
const view = new VariantAnalysisView(
4251
this.ctx,
4352
variantAnalysisState.variantAnalysisId,

0 commit comments

Comments
 (0)