Skip to content

fix: suppress View output when executing a subprocess#1687

Open
blackwell-systems wants to merge 1 commit into
charmbracelet:mainfrom
blackwell-systems:fix/exec-suppress-view-output
Open

fix: suppress View output when executing a subprocess#1687
blackwell-systems wants to merge 1 commit into
charmbracelet:mainfrom
blackwell-systems:fix/exec-suppress-view-output

Conversation

@blackwell-systems
Copy link
Copy Markdown

The bug

When ExecProcess (or Exec) runs a subprocess, 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.

The existing workaround is to set a quitting flag and return "" from View() before returning the ExecProcess command (see this gist). This is error-prone and shouldn't be required.

The fix

Render an empty View{} before calling releaseTerminal in exec(). When stopRenderer flushes, the empty view produces no output (the renderer sets frame height to 0 when content is empty). This is the same effect as the manual workaround, applied automatically by the framework.

Changes

One file: exec.go. 5 lines of code added (plus comments).

Compiles, go test ./... passes, go vet clean.

Fixes #431

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 charmbracelet#431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tea.ExecProcess writes View output to stdout before executing the command

1 participant