page-up/down: undo last up/down if items are skipped

Fix #4069
This commit is contained in:
Junegunn Choi 2024-11-09 11:54:41 +09:00
parent 9c94f9c3d0
commit ca3f6181d7
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -4468,13 +4468,16 @@ func (t *Terminal) Loop() error {
}
}
for ; linesToMove > 0; linesToMove-- {
cy := t.cy
for i := 0; i < linesToMove; i++ {
cy, offset := t.cy, t.offset
t.vset(cy + direction)
t.constrain()
if cy == t.cy ||
direction > 0 && t.offset >= maxOffset ||
direction < 0 && t.offset <= minOffset {
if cy == t.cy {
break
}
if i > 0 && (direction > 0 && t.offset > maxOffset ||
direction < 0 && t.offset < minOffset) {
t.cy, t.offset = cy, offset
break
}
}