From df1e10c971badb186f6867a8428b2ec191460ac7 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 14 Apr 2026 08:35:45 -0600 Subject: [PATCH 1/2] Terminate Quarto preview when terminal is closed externally --- apps/vscode/src/providers/preview/preview.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/vscode/src/providers/preview/preview.ts b/apps/vscode/src/providers/preview/preview.ts index afe2cb49..5a36daf4 100644 --- a/apps/vscode/src/providers/preview/preview.ts +++ b/apps/vscode/src/providers/preview/preview.ts @@ -282,6 +282,18 @@ class PreviewManager { this.outputSink_, this.renderToken_ ); + + // When the user closes the preview terminal via the trash icon (or any + // external means), send the HTTP termination request so Quarto can clean + // up temp files (e.g. _ipynb files created during Python preview). + context.subscriptions.push( + vscode.window.onDidCloseTerminal(async (closedTerminal) => { + if (closedTerminal === this.terminal_) { + this.terminal_ = undefined; + await this.previewTerminateRequest(); + } + }) + ); } dispose() { @@ -416,6 +428,9 @@ class PreviewManager { } private async killPreview() { + // Clear this.terminal_ before disposing so the onDidCloseTerminal listener + // does not send a duplicate termination request. + this.terminal_ = undefined; await killTerminal(kPreviewWindowTitle, async () => await this.previewTerminateRequest()); this.progressDismiss(); this.progressCancellationToken_ = undefined; From 89a48275284e3db8ee259e31aaede66a2d025589 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 14 Apr 2026 08:57:01 -0600 Subject: [PATCH 2/2] Update CHANGELOG --- apps/vscode/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index 8a17652d..8034dd46 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -5,6 +5,7 @@ - Added support for Positron's statement execution feature that reports the approximate line number of the parse error (). - Fixed a bug where `Quarto: Format Cell` would notify you that no formatter was available for code cells that were already formatted (). - No longer claim `.typ` files. Typst syntax highlighting in Quarto documents is unaffected, but standalone Typst files are now left to dedicated extensions like Tinymist (). +- Fixed a bug where closing the Quarto Preview terminal via the trash icon did not clean up intermediate `.quarto_ipynb` files (). ## 1.130.0 (Release on 2026-02-18)