All completion tests pass again

This commit is contained in:
Kovid Goyal
2022-09-26 11:54:57 +05:30
parent 262e2fb7a3
commit 3bd4fd999a
5 changed files with 7 additions and 3 deletions

View File

@@ -31,6 +31,8 @@ type Command struct {
ArgCompleter CompletionFunc
// Stop completion processing at this arg num
StopCompletingAtArg int
// Consider all args as non-options args
OnlyArgsAllowed bool
// Specialised arg aprsing
ParseArgsForCompletion func(cmd *Command, args []string, completions *Completions)

View File

@@ -187,7 +187,7 @@ func completion_parse_args(cmd *Command, words []string, completions *Completion
cmd = sc
arg_num = 0
completions.CurrentWordIdxInParent = 0
only_args_allowed = false
only_args_allowed = cmd.OnlyArgsAllowed
if cmd.ParseArgsForCompletion != nil {
cmd.ParseArgsForCompletion(cmd, words[i+1:], completions)
return

View File

@@ -155,7 +155,7 @@ func ChainCompleters(completers ...CompletionFunc) CompletionFunc {
func CompletionForWrapper(wrapped_cmd string) func(completions *Completions, word string, arg_num int) {
return func(completions *Completions, word string, arg_num int) {
completions.Delegate.NumToRemove = completions.CurrentWordIdx + 1
completions.Delegate.NumToRemove = completions.CurrentWordIdx
completions.Delegate.Command = wrapped_cmd
}
}