More completion work

This commit is contained in:
Kovid Goyal
2022-09-16 17:29:41 +05:30
parent 946d44c43f
commit 0ff2446a1a
7 changed files with 46 additions and 5 deletions

View File

@@ -100,7 +100,7 @@ func complete_word(word string, completions *Completions, only_args_allowed bool
}
return
}
if arg_num == 1 && cmd.has_subcommands() {
if cmd.has_subcommands() && cmd.sub_command_allowed_at(completions, arg_num) {
for _, cg := range cmd.Groups {
group := completions.add_match_group(cg.Title)
if group.Title == "" {
@@ -163,7 +163,7 @@ func (cmd *Command) parse_args(words []string, completions *Completions) {
}
continue
}
if cmd.has_subcommands() && arg_num == 1 {
if cmd.has_subcommands() && cmd.sub_command_allowed_at(completions, arg_num) {
sc := cmd.find_subcommand_with_name(word)
if sc == nil {
only_args_allowed = true