summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-03-17 15:55:16 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-03-17 15:55:16 +0900
commitc7ee071efa0f988ba9613166798afc4b300ce761 (patch)
tree301fbc9205b22e88bd164ac9c03c985d55d4bd86
parent0740ef7ceb717676c7d8328a655e1554e1b0d366 (diff)
Fix panic caused by invalid cursor index
Fix #3681
-rw-r--r--src/terminal.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/terminal.go b/src/terminal.go
index b24950e8..04e1d3a9 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1060,11 +1060,11 @@ func (t *Terminal) UpdateProgress(progress float32) {
// UpdateList updates Merger to display the list
func (t *Terminal) UpdateList(merger *Merger) {
t.mutex.Lock()
- var prevIndex int32 = -1
+ prevIndex := minItem.Index()
reset := t.revision != merger.Revision()
if !reset && t.track != trackDisabled {
if t.merger.Length() > 0 {
- prevIndex = t.merger.Get(t.cy).item.Index()
+ prevIndex = t.currentIndex()
} else if merger.Length() > 0 {
prevIndex = merger.First().item.Index()
}
@@ -4121,7 +4121,7 @@ func (t *Terminal) constrain() {
// count of lines can be displayed
height := t.maxItems()
- t.cy = util.Constrain(t.cy, 0, count-1)
+ t.cy = util.Constrain(t.cy, 0, util.Max(0, count-1))
minOffset := util.Max(t.cy-height+1, 0)
maxOffset := util.Max(util.Min(count-height, t.cy), 0)