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(); } }