Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
"cmd",
"addcustominfo",
"bottom",
"builtin",
"calcdirsize",
"cd",
"clear",
Expand Down Expand Up @@ -473,6 +474,10 @@ func completeCmd(acc []rune) (matches []compMatch, result string) {
if len(f) == 2 {
matches, result = matchCmdFile(f[1], false)
}
case "builtin":
if len(f) == 2 {
matches, result = matchCmd(f[1])
}
case "toggle":
matches, result = matchCmdFile(f[len(f)-1], false)
default:
Expand Down
28 changes: 22 additions & 6 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,27 @@ func exitCompMenu(app *app) {
func (e *callExpr) eval(app *app, _ []string) {
os.Setenv("lf_count", strconv.Itoa(e.count))

noOverride := []string{
"open",
"paste",
"delete",
"rename",
}

if e.name == "builtin" {
if len(e.args) == 0 {
app.ui.echoerr("builtin: requires at least 1 argument")
return
} else if e.args[0] == "builtin" {
app.ui.echoerr("builtin: recursive call")
return
}
e.name, e.args = e.args[0], e.args[1:]
} else if cmd, ok := gOpts.cmds[e.name]; ok && !slices.Contains(noOverride, e.name) {
cmd.eval(app, e.args)
return
}

silentCmds := []string{
"addcustominfo",
"clearmaps",
Expand Down Expand Up @@ -2260,12 +2281,7 @@ func (e *callExpr) eval(app *app, _ []string) {
case "on-init":
onInit(app)
default:
cmd, ok := gOpts.cmds[e.name]
if !ok {
app.ui.echoerrf("command not found: %s", e.name)
return
}
cmd.eval(app, e.args)
app.ui.echoerrf("command not found: %s", e.name)
}
}

Expand Down