Skip to content

Commit

Permalink
Merge pull request #167 from skogsbaer/close-old-viz-tab
Browse files Browse the repository at this point in the history
Close old visualization tab when a new tab opens
  • Loading branch information
skogsbaer authored Dec 4, 2024
2 parents 53de079 + 035beb2 commit d29f42a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/programflow-visualization/frontend/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { VisualizationPanel } from './visualization_panel';
import { MessagePort } from 'worker_threads';
import * as TraceCache from '../trace_cache';

let panel: VisualizationPanel | undefined = undefined;

export async function startFrontend(
context: ExtensionContext,
filePath: string,
Expand All @@ -13,7 +15,8 @@ export async function startFrontend(
trace = await TraceCache.getTrace(context, fileHash);
}

const panel = await VisualizationPanel.getVisualizationPanel(context, filePath, fileHash, trace, tracePort);
panel?.dispose();
panel = await VisualizationPanel.getVisualizationPanel(context, filePath, fileHash, trace, tracePort);
if (!panel) {
return failure("Frontend couldn't be initialized!");
}
Expand Down
4 changes: 4 additions & 0 deletions src/programflow-visualization/frontend/visualization_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export class VisualizationPanel {
});
}

public dispose() {
this._panel?.dispose();
}

public static async getVisualizationPanel(
context: vscode.ExtensionContext,
filePath: string,
Expand Down

0 comments on commit d29f42a

Please sign in to comment.