Repository: gokcehan/lf (language: go)

Issue:
the r29 version , the 'map G bottom' seting not working
![image](https://github.com/gokcehan/lf/assets/87791643/989dde94-2179-4988-a68d-04dccf995b95)



Discussion / hints:
Thanks for reporting, I can replicate just by typing `:bottom` into the command line.

Previously the `bottom` command would just unconditionally move to the bottom, but after b5c83db it allows for a count variable to specify moving to a specific line. For example, pressing <kbd>3G</kbd> means to move to the third line. The default <kbd>G</kbd> keybinding uses a count of 0 so it should still work, but not if you remap it manually.

The problem is that by default commands are parsed with a count of 1: https://github.com/gokcehan/lf/blob/f04401ba4d43f21a084e603a52cf20f80b0c437d/parse.go#L221-L231

This usually works, but I guess `bottom` would have to be treated differently.

Fix patch:
diff --git a/eval.go b/eval.go
index 74532843..d66257ea 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 c4a17681..f20584a7 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}


Test patch: