fix(ui): early exit AtBottom() when totalHeight exceeds viewport height
Related: https://github.com/charmbracelet/crush/issues/2226
commite471e75e7d732e2d88088f60d1abbe81aa0c897c
authorAyman Bagabas <ayman.bagabas@gmail.com>
dateMon 16 Feb 2026, 14:08 (8 months ago)
parent7aa191d
internal/ui/list/list.go+4
@@ -84,6 +84,10 @@ func (l *List) AtBottom() bool {
8484 // Calculate the height from offsetIdx to the end.
8585 var totalHeight int
8686 for idx := l.offsetIdx; idx < len(l.items); idx++ {
87+ if totalHeight > l.height {
88+ // No need to calculate further, we're already past the viewport height
89+ return false
90+ }
8791 item := l.getItem(idx)
8892 itemHeight := item.height
8993 if l.gap > 0 && idx > l.offsetIdx {