From fd5101a3f63ef605bb349d9a793be6a7b1b35acd Mon Sep 17 00:00:00 2001 From: Dayna Blackwell Date: Mon, 27 Apr 2026 16:34:20 -0700 Subject: [PATCH] fix: suppress View output when executing a subprocess When ExecProcess runs, the renderer's final flush writes the current View() output to stdout before the subprocess takes over. This content persists in the terminal after the subprocess exits, requiring users to work around it by returning an empty string from View(). Render an empty view before releasing the terminal so the flush has nothing to write. Fixes #431 --- exec.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exec.go b/exec.go index e8af5c42fe..10199d62bf 100644 --- a/exec.go +++ b/exec.go @@ -100,6 +100,14 @@ func (c *osExecCommand) SetStderr(w io.Writer) { // exec runs an ExecCommand and delivers the results to the program as a Msg. func (p *Program) exec(c ExecCommand, fn ExecCallback) { + // Clear the current view before releasing the terminal so the renderer's + // final flush doesn't write the last View() output to stdout. Without + // this, the view content leaks to the terminal and persists after the + // subprocess exits. + if p.renderer != nil { + p.renderer.render(View{}) + } + if err := p.releaseTerminal(false); err != nil { // If we can't release input, abort. if fn != nil {