Fix (half-)page-up/down in the presence of multi-line items

Fix #4069
This commit is contained in:
Junegunn Choi 2024-10-30 16:52:42 +09:00
parent ff1687744d
commit 82ebcd9209
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -4410,17 +4410,32 @@ func (t *Terminal) Loop() error {
suffix := copySlice(t.input[t.cx:]) suffix := copySlice(t.input[t.cx:])
t.input = append(append(t.input[:t.cx], t.yanked...), suffix...) t.input = append(append(t.input[:t.cx], t.yanked...), suffix...)
t.cx += len(t.yanked) t.cx += len(t.yanked)
case actPageUp: case actPageUp, actPageDown, actHalfPageUp, actHalfPageDown:
t.vmove(t.maxItems()-1, false) maxItems := t.maxItems()
req(reqList) linesToMove := maxItems - 1
case actPageDown: if a.t == actHalfPageUp || a.t == actHalfPageDown {
t.vmove(-(t.maxItems() - 1), false) linesToMove = maxItems / 2
req(reqList) }
case actHalfPageUp:
t.vmove(t.maxItems()/2, false) direction := -1
req(reqList) if a.t == actPageUp || a.t == actHalfPageUp {
case actHalfPageDown: direction = 1
t.vmove(-(t.maxItems() / 2), false) }
for linesToMove > 0 {
currentItem := t.currentItem()
if currentItem == nil {
break
}
itemLines, _ := t.numItemLines(currentItem, maxItems)
linesToMove -= itemLines
cy := t.cy
t.vmove(direction, false)
if cy == t.cy {
break
}
}
req(reqList) req(reqList)
case actOffsetUp, actOffsetDown: case actOffsetUp, actOffsetDown:
diff := 1 diff := 1