Skip to content

Fix panic when the terminal is shorter than two rows - #525

Open
VXNCXNX wants to merge 1 commit into
imsnif:mainfrom
VXNCXNX:fix/tiny-terminal-panic
Open

Fix panic when the terminal is shorter than two rows#525
VXNCXNX wants to merge 1 commit into
imsnif:mainfrom
VXNCXNX:fix/tiny-terminal-panic

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 17, 2026

Copy link
Copy Markdown

bandwhich panics and exits when the terminal is fewer than two rows tall, for instance a small tmux pane or a resize while running:

thread 'display_handler' panicked at src/display/components/layout.rs:18:36:
attempt to subtract with overflow

top_app_and_bottom_split does rect.height - 2 on a u16 to 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 plain saturating_sub on all three stops the panic but silently drops the header at height 1, so the rows are allocated explicitly instead.

Two tests in layout.rs covering 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 real Layout through TestBackend. cargo test passes (16), fmt and clippy --all-targets --all-features -- -D warnings clean. The ui_test suite is red on a clean checkout from a ratatui bump and off by default, so these run under plain cargo test.

AI disclosure: written with Claude Code. I ran the tests and checked both mutations myself.

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.
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.

1 participant