Repository navigation
Conversation
in_terminal requested the cursor position and repainted right away, before the response arrived. That paint doesn't know how many rows are free below the cursor, so the layout gets its preferred height, right below the new output. When the response arrives the layout is painted again, extended to the bottom of the terminal. For layouts that fill the remaining space (a bottom toolbar), every run_in_terminal call, including every patch_stdout flush, made them jump up and back down. Keep rendering disabled until the response arrives (or the existing CPR timeout expires), then paint once.
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.
Fixes #2115.
in_terminalrequested the cursor position and repainted straight away. The renderer didn't know the space below the cursor yet, so layouts that fill the rest of the terminal were painted right under the new output, then painted again at the bottom once the response arrived. Withpatch_stdoutthat's a jump on every flush.This keeps
_running_in_terminalset while waiting for the response withrenderer.wait_for_cpr_responses(), then clears it and redraws once. Invalidations that come in during the wait (key presses, refresh timers) are dropped like they are during the body, and the explicit redraw afterwards covers them.Fallbacks are unchanged:
NOT_SUPPORTED, return from the wait immediately.wait_for_cpr_responsesapplies and the app repaints as before.finally.One trade-off: on a high latency connection, the app now stays erased for one CPR round trip instead of showing a frame in the wrong place for that long and then jumping.
I added
tests/test_run_in_terminal.py, which drives an inline app through a pipe input and a Vt100 output that responds to CPR. It checks that the first paint afterin_terminalalready knows the available height, and that the app still repaints when no response arrives. The first test fails on main.