Skip to content

Commit

Permalink
Fix count when parsing bottom command (#1240)
Browse files Browse the repository at this point in the history
* Fix count when parsing `bottom` command

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

This reverts commit a0b6bb5.

* Alternate implementation

* Add comment
  • Loading branch information
joelim-work authored May 13, 2023
1 parent 24e224c commit 88b3c99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 88b3c99

Please sign in to comment.