Skip to content

Commit

Permalink
page-up/down: undo last up/down if items are skipped
Browse files Browse the repository at this point in the history
Fix #4069
  • Loading branch information
junegunn committed Nov 9, 2024
1 parent 9c94f9c commit ca3f618
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit ca3f618

Please sign in to comment.