Fix panic when the terminal is shorter than two rows - #525
Open
VXNCXNX wants to merge 1 commit into
Open
Conversation
Layout constraints now degrade gracefully by priority: header, then footer, then tables. This prevents u16 underflow panics when the terminal height is less than two rows.
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.
bandwhich panics and exits when the terminal is fewer than two rows tall, for instance a small tmux pane or a resize while running:
top_app_and_bottom_splitdoesrect.height - 2on au16to size the middle region, which underflows at height 0 or 1. The three constraints now degrade by priority: the header gets the first row, the footer the second, the tables whatever is left. A plainsaturating_subon all three stops the panic but silently drops the header at height 1, so the rows are allocated explicitly instead.Two tests in
layout.rscovering heights 0 to 4: one asserts the regions sum to the available height and that header and footer win in that order, the other renders the realLayoutthroughTestBackend.cargo testpasses (16), fmt andclippy --all-targets --all-features -- -D warningsclean. Theui_testsuite is red on a clean checkout from a ratatui bump and off by default, so these run under plaincargo test.AI disclosure: written with Claude Code. I ran the tests and checked both mutations myself.