on main help sign in
fix(ui): early exit AtBottom() when totalHeight exceeds viewport height
e471e75Ayman Bagabas
internal/ui/list/list.go+4
@@ -84,6 +84,10 @@ func (l *List) AtBottom() bool {
84 // Calculate the height from offsetIdx to the end.
84 // Calculate the height from offsetIdx to the end.
85 var totalHeight int
85 var totalHeight int
86 for idx := l.offsetIdx; idx < len(l.items); idx++ {
86 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+ }
87 item := l.getItem(idx)
91 item := l.getItem(idx)
88 itemHeight := item.height
92 itemHeight := item.height
89 if l.gap > 0 && idx > l.offsetIdx {
93 if l.gap > 0 && idx > l.offsetIdx {