Skip to content

Commit ec9bdad

Browse files
authored
Fix low/high crash for big scrolloff values (#1504)
1 parent 03b7321 commit ec9bdad

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nav.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ func (nav *nav) high() bool {
11441144

11451145
old := dir.ind
11461146
beg := max(dir.ind-dir.pos, 0)
1147-
offs := gOpts.scrolloff
1147+
offs := min(nav.height/2, gOpts.scrolloff)
11481148
if beg == 0 {
11491149
offs = 0
11501150
}
@@ -1175,7 +1175,14 @@ func (nav *nav) low() bool {
11751175
old := dir.ind
11761176
beg := max(dir.ind-dir.pos, 0)
11771177
end := min(beg+nav.height, len(dir.files))
1178-
offs := gOpts.scrolloff
1178+
1179+
offs := min(nav.height/2, gOpts.scrolloff)
1180+
// use a smaller value for half when the height is even and scrolloff is
1181+
// maxed in order to stay at the same row when using both high and low
1182+
if nav.height%2 == 0 {
1183+
offs = min(nav.height/2-1, gOpts.scrolloff)
1184+
}
1185+
11791186
if end == len(dir.files) {
11801187
offs = 0
11811188
}

0 commit comments

Comments
 (0)