diff --git a/eval.go b/eval.go index 6519a7a..1408e10 100644 --- a/eval.go +++ b/eval.go @@ -606,44 +606,50 @@ func (e *callExpr) eval(app *app, args []string) { if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.up(e.count) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.up(e.count) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "half-up": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.up(e.count * app.nav.height / 2) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.up(e.count * app.nav.height / 2) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "page-up": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.up(e.count * app.nav.height) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.up(e.count * app.nav.height) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "down": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.down(e.count) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.down(e.count) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "half-down": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.down(e.count * app.nav.height / 2) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.down(e.count * app.nav.height / 2) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "page-down": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) } - app.nav.down(e.count * app.nav.height) - app.ui.loadFile(app.nav, true) - app.ui.loadFileInfo(app.nav) + if app.nav.down(e.count * app.nav.height) { + app.ui.loadFile(app.nav, true) + app.ui.loadFileInfo(app.nav) + } case "updir": if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" { normal(app) diff --git a/nav.go b/nav.go index da190e6..6c4b26f 100644 --- a/nav.go +++ b/nav.go @@ -590,14 +590,16 @@ func (nav *nav) sort() { } } -func (nav *nav) up(dist int) { +func (nav *nav) up(dist int) bool { dir := nav.currDir() + old := dir.ind + if dir.ind == 0 { if gOpts.wrapscroll { nav.bottom() } - return + return old != dir.ind } dir.ind -= dist @@ -606,18 +608,22 @@ func (nav *nav) up(dist int) { dir.pos -= dist edge := min(min(nav.height/2, gOpts.scrolloff), dir.ind) dir.pos = max(dir.pos, edge) + + return old != dir.ind } -func (nav *nav) down(dist int) { +func (nav *nav) down(dist int) bool { dir := nav.currDir() + old := dir.ind + maxind := len(dir.files) - 1 if dir.ind >= maxind { if gOpts.wrapscroll { nav.top() } - return + return old != dir.ind } dir.ind += dist @@ -632,6 +638,8 @@ func (nav *nav) down(dist int) { dir.pos = min(dir.pos, nav.height-edge-1) dir.pos = min(dir.pos, maxind) + + return old != dir.ind } func (nav *nav) updir() error {