Skip to content

Commit

Permalink
Fix low/high crash for big scrolloff values (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelim-work authored Dec 11, 2023
1 parent 03b7321 commit ec9bdad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ func (nav *nav) high() bool {

old := dir.ind
beg := max(dir.ind-dir.pos, 0)
offs := gOpts.scrolloff
offs := min(nav.height/2, gOpts.scrolloff)
if beg == 0 {
offs = 0
}
Expand Down Expand Up @@ -1175,7 +1175,14 @@ func (nav *nav) low() bool {
old := dir.ind
beg := max(dir.ind-dir.pos, 0)
end := min(beg+nav.height, len(dir.files))
offs := gOpts.scrolloff

offs := min(nav.height/2, gOpts.scrolloff)
// use a smaller value for half when the height is even and scrolloff is
// maxed in order to stay at the same row when using both high and low
if nav.height%2 == 0 {
offs = min(nav.height/2-1, gOpts.scrolloff)
}

if end == len(dir.files) {
offs = 0
}
Expand Down

0 comments on commit ec9bdad

Please sign in to comment.