From 188bd97b3b6b397cbb514ca3edffaf208407e061 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 2 Sep 2016 22:47:11 +0300 Subject: [PATCH] fix jiggle when scrolloff is maxed --- eval.go | 3 +-- nav.go | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eval.go b/eval.go index 86bca8c..fccfdd6 100644 --- a/eval.go +++ b/eval.go @@ -39,9 +39,8 @@ func (e *SetExpr) eval(app *App, args []string) { log.Print(msg) return } - max := app.ui.wins[0].h/2 - 1 + max := app.ui.wins[0].h/2 if n > max { - // TODO: stay at the same row while up/down in the middle n = max } gOpts.scrolloff = n diff --git a/nav.go b/nav.go index fb5ea23..e9dab33 100644 --- a/nav.go +++ b/nav.go @@ -260,6 +260,11 @@ func (nav *Nav) down() { dir.pos++ edge := min(gOpts.scrolloff, maxind-dir.ind) + + // use a smaller value when the height is even and scrolloff is maxed + // in order to stay at the same row as much as possible while up/down + edge = min(edge, nav.height / 2 + nav.height % 2 - 1) + dir.pos = min(dir.pos, nav.height-edge-1) dir.pos = min(dir.pos, maxind) }