summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Lim <50560759+joelim-work@users.noreply.github.com>2023-05-13 23:58:21 +1000
committerGitHub <noreply@github.com>2023-05-13 16:58:21 +0300
commit88b3c999afb7cab8e8ca61da3c9063f0cc348c10 (patch)
treee3fa47df566fb88e56245f3ab98c7cfa1814d4c3
parent24e224ca65c0e2f7b80cb0b33606f1de14bf9264 (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.go6
-rw-r--r--opts.go8
2 files changed, 8 insertions, 6 deletions
diff --git a/eval.go b/eval.go
index 8fdf96d..0a6ca6e 100644
--- a/eval.go
+++ b/eval.go
@@ -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)
diff --git a/opts.go b/opts.go
index 62830a6..301a364 100644
--- a/opts.go
+++ b/opts.go
@@ -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}