fix: suppress View output when executing a subprocess#1687
Open
blackwell-systems wants to merge 1 commit into
Open
fix: suppress View output when executing a subprocess#1687blackwell-systems wants to merge 1 commit into
blackwell-systems wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
When
ExecProcess(orExec) runs a subprocess, the renderer's final flush writes the currentView()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
quittingflag and return""fromView()before returning theExecProcesscommand (see this gist). This is error-prone and shouldn't be required.The fix
Render an empty
View{}before callingreleaseTerminalinexec(). WhenstopRendererflushes, 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 vetclean.Fixes #431