Fix table viewport panic on small terminal windows#141
Merged
Conversation
The table height calculation subtracts 35 lines of overhead from the
terminal height, producing a negative value for any terminal under 36
lines (including standard 24-line terminals). This was clamped to 1,
but table.SetHeight(1) internally subtracts the 2-line header height
(text + bottom border), giving the viewport a height of -1. This
caused either invisible table rows or a panic in viewport.visibleLines
("slice bounds out of range [2:1]") depending on timing.
Raise the minimum tableHeight from 1 to 4 so the viewport always gets
at least 2 lines of content space after the header is subtracted.
Add TestWindowSizeMsgHandler_SmallWindow covering standard 80x24,
tiny, minimum, and zero-height terminals.
Created with assistance from Claude 🤖 <claude@anthropic.com>
Signed-off-by: Christopher Collins <collins.christopher@gmail.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.
Summary
slice bounds out of range [2:1]) caused by negative viewport height when terminal is under 36 lines tall (including standard 24-line terminals)table.SetHeight(1)internally subtracts the 2-line styled header, producingviewport.Height = -1tableHeightfrom 1 to 4 so the viewport always has positive height after header subtractionTestWindowSizeMsgHandler_SmallWindowcovering standard, tiny, minimum, and zero-height terminalsTest plan
go test ./pkg/tui/ -run TestWindowSizeMsgHandler_SmallWindow -vpassesgo test ./...full suite passesgo buildsucceeds🤖 Generated with Claude Code