From 1616ed543dd250f68852007a5e2e44d8937e4302 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 6 Jun 2024 00:23:58 +0900 Subject: [PATCH] Fix index out of bounds error caused by outdated offset --- src/terminal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index 60cc6f33..7846e662 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -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?