Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix low/high crash for big scrolloff values #1504

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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