Fix count when parsing bottom command (#1240)

* Fix count when parsing `bottom` command

* Revert "Fix count when parsing `bottom` command"

This reverts commit a0b6bb5a13.

* Alternate implementation

* Add comment
This commit is contained in:
Joe Lim authored and GitHub committed 2023-05-13 16:58:21 +03:00
1 parent 24e224ca65
commit 88b3c999af
2 files changed
+8 -6

No files matched your search

+4 -2
View File
@@ -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)
+4 -4
View File
@@ -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}