From 605172a85167c47ddcf5685238922df9c878faa0 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Fri, 20 Nov 2026 04:59:13 +1100 Subject: [PATCH] An already-cancelled test-debug gesture opens no terminal, and a run's end disposes its terminal window, so a terminal VS Code never opened can no longer outlive its run --- src/editors/vscode/src/test-debug.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/editors/vscode/src/test-debug.ts b/src/editors/vscode/src/test-debug.ts index 0209b535..04c49254 100644 --- a/src/editors/vscode/src/test-debug.ts +++ b/src/editors/vscode/src/test-debug.ts @@ -205,6 +205,8 @@ class DebugRunFlow { this.onFirstAttach = resolve; }); private announcements: Promise = Promise.resolve(); + /** The run's terminal window, when the gesture opened one. */ + private window: vscode.Terminal | undefined; private finished = false; private readonly watcher = new TestHostWatcher((pid) => { this.queueHost(pid); @@ -236,7 +238,15 @@ class DebugRunFlow { const bridge = token.onCancellationRequested(() => { this.stop.abort(); }); - vscode.window.createTerminal({ name: TEST_DEBUG_TERMINAL_NAME, pty: this.terminal }).show(true); + // An already-cancelled gesture runs nothing worth showing: opening a + // terminal for it only leaves a ghost beside the next run. + if (!this.stop.signal.aborted) { + this.window = vscode.window.createTerminal({ + name: TEST_DEBUG_TERMINAL_NAME, + pty: this.terminal, + }); + this.window.show(true); + } try { await Promise.race([this.attached, this.settle()]); } finally { @@ -261,6 +271,9 @@ class DebugRunFlow { this.endedWaiters.clear(); this.run.end(); this.terminal.end(); + // The pty's close only reaches a terminal VS Code has opened; disposing + // the window itself closes one it never opened, too. + this.window?.dispose(); } }