Fix index out of bounds error caused by outdated offset

This commit is contained in:
Junegunn Choi 2024-06-06 00:23:58 +09:00
parent dc73fba188
commit 1616ed543d
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -4574,7 +4574,7 @@ func (t *Terminal) constrain() {
maxLines := t.maxItems()
// May need to try again after adjusting the offset
t.offset = util.Max(0, t.offset) // Prevent -1
t.offset = util.Constrain(t.offset, 0, count)
for tries := 0; tries < maxLines; tries++ {
numItems := maxLines
// How many items can be fit on screen including the current item?