Implement completer for "del".

This fixes #1774.
This commit is contained in:
Qi Xiao 2024-03-22 13:59:58 +00:00
parent b0a1305db1
commit 64efe7305e
2 changed files with 20 additions and 0 deletions

View File

@ -206,6 +206,16 @@ func TestComplete(t *testing.T) {
ci("local-var1"), ci("local-var2"),
},
}),
// "del" has a similar completer.
Args(cb("del "), ev, cfg).Rets(
&Result{
Name: "argument", Replace: r(4, 4),
Items: []modes.CompletionItem{
ci("local-fn1~"), ci("local-fn2~"),
ci("local-ns1:"), ci("local-ns2:"),
ci("local-var1"), ci("local-var2"),
},
}),
// Complete commands at an empty buffer, generating special forms,
// externals, functions, namespaces and variable assignments.

View File

@ -63,6 +63,16 @@ func generateArgs(args []string, ev *eval.Evaler, p np.Path, cfg Config) ([]RawI
items = append(items, noQuoteItem(sigil+parse.QuoteVariableName(ns+varname)))
})
return items, nil
case "del":
// This partially duplicates eachVariableInNs with ns = "", but we don't
// offer builtin variables.
var items []RawItem
addItem := func(varname string) {
items = append(items, noQuoteItem(parse.QuoteVariableName(varname)))
}
ev.Global().IterateKeysString(addItem)
eachDefinedVariable(p[len(p)-1], p[0].Range().From, addItem)
return items, nil
}
return cfg.ArgGenerator(args)