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

Fix #4069
This commit is contained in:
Junegunn Choi
2024-11-07 22:21:07 +09:00
parent d4d9b99879
commit 4a85843bcf

View File

@@ -4422,6 +4422,7 @@ func (t *Terminal) Loop() error {
direction = 1 direction = 1
} }
moved := false
for linesToMove > 0 { for linesToMove > 0 {
currentItem := t.currentItem() currentItem := t.currentItem()
if currentItem == nil { if currentItem == nil {
@@ -4430,11 +4431,15 @@ func (t *Terminal) Loop() error {
itemLines, _ := t.numItemLines(currentItem, maxItems) itemLines, _ := t.numItemLines(currentItem, maxItems)
linesToMove -= itemLines linesToMove -= itemLines
if moved && linesToMove < 0 {
break
}
cy := t.cy cy := t.cy
t.vmove(direction, false) t.vmove(direction, false)
if cy == t.cy { if cy == t.cy {
break break
} }
moved = true
} }
req(reqList) req(reqList)
case actOffsetUp, actOffsetDown: case actOffsetUp, actOffsetDown: