Repository navigation
Redraw cleanly when the terminal is resized - #4
Merged
Merged
Conversation
The picker redrew on SIGWINCH, but it moved back up as many rows as it had drawn lines above the prompt: one. Terminals rewrap their lines when narrowed, so the full-width header now took two rows or more, the redraw started in the middle of it, and every resize left a stale header above the picker. The picker now keeps the widths of the lines it drew, and on a resize finds its top again from how they rewrap at the new width. The list's height is also recomputed, so it fits a terminal made shorter and uses one made taller. Version 0.2.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Resizing the terminal while
wtwas open left the display mangled: each resize stacked another copy of the header above the picker.Why
The picker already redrew on
SIGWINCH. Before redrawing, it moved up one row per line drawn above the prompt, which is one row for the header. Terminals rewrap their lines when the window gets narrower, so the full-width header now took two or more rows. The redraw started partway through it, and the old header stayed on screen above.What changed
resize()works out how many rows the header and the start of the prompt line take at the new width (rowsAbove), then redraws from the real top of the picker. A wider window changes nothing.Limits
Testing
visibleLenandrowsAbove. Lint, the tests and the smoke test pass.wt, drag the window narrower and wider, shorter and taller.🤖 Generated with Claude Code