diff options
author | Joe Lim <50560759+joelim-work@users.noreply.github.com> | 2023-05-13 23:58:21 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 16:58:21 +0300 |
commit | 88b3c999afb7cab8e8ca61da3c9063f0cc348c10 (patch) | |
tree | e3fa47df566fb88e56245f3ab98c7cfa1814d4c3 | |
parent | 24e224ca65c0e2f7b80cb0b33606f1de14bf9264 (diff) |
Fix count when parsing `bottom` command (#1240)r30
* Fix count when parsing `bottom` command
* Revert "Fix count when parsing `bottom` command"
This reverts commit a0b6bb5a13648760c3a69d94030e5b1b63b9db14.
* Alternate implementation
* Add comment
-rw-r--r-- | eval.go | 6 | ||||
-rw-r--r-- | opts.go | 8 |
2 files changed, 8 insertions, 6 deletions
@@ -1447,7 +1447,7 @@ func (e *callExpr) eval(app *app, args []string) { return } var moved bool - if e.count == 0 { + if e.count == 1 { moved = app.nav.top() } else { moved = app.nav.move(e.count - 1) @@ -1461,7 +1461,9 @@ func (e *callExpr) eval(app *app, args []string) { return } var moved bool - if e.count == 0 { + if e.count == 1 { + // Different from Vim, which would treat a count of 1 as meaning to + // move to the first line (i.e. the top) moved = app.nav.bottom() } else { moved = app.nav.move(e.count - 1) @@ -163,10 +163,10 @@ func init() { gOpts.keys["l"] = &callExpr{"open", nil, 1} gOpts.keys["<right>"] = &callExpr{"open", nil, 1} gOpts.keys["q"] = &callExpr{"quit", nil, 1} - gOpts.keys["gg"] = &callExpr{"top", nil, 0} - gOpts.keys["<home>"] = &callExpr{"top", nil, 0} - gOpts.keys["G"] = &callExpr{"bottom", nil, 0} - gOpts.keys["<end>"] = &callExpr{"bottom", nil, 0} + gOpts.keys["gg"] = &callExpr{"top", nil, 1} + gOpts.keys["<home>"] = &callExpr{"top", nil, 1} + gOpts.keys["G"] = &callExpr{"bottom", nil, 1} + gOpts.keys["<end>"] = &callExpr{"bottom", nil, 1} gOpts.keys["H"] = &callExpr{"high", nil, 1} gOpts.keys["M"] = &callExpr{"middle", nil, 1} gOpts.keys["L"] = &callExpr{"low", nil, 1} |