From ef9b765f818b0f909328a908cbd6ec7edaa41ca5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Sep 2022 20:48:07 +0530 Subject: [PATCH] Dont count bash's idiotic option equals as arguments --- tools/completion/parse-args.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/completion/parse-args.go b/tools/completion/parse-args.go index 6020d9a2b..e61f1535d 100644 --- a/tools/completion/parse-args.go +++ b/tools/completion/parse-args.go @@ -146,20 +146,23 @@ func default_parse_args(cmd *Command, words []string, completions *Completions) completions.current_word_idx = i completions.current_word_idx_in_parent++ is_last_word := i == len(words)-1 + is_option_equal := completions.split_on_equals && word == "=" && expecting_arg_for != nil if only_args_allowed || (expecting_arg_for == nil && !strings.HasPrefix(word, "-")) { - arg_num++ + if !is_option_equal { + arg_num++ + } if arg_num == 1 { cmd.index_of_first_arg = completions.current_word_idx } } if is_last_word { - if completions.split_on_equals && word == "=" { + if is_option_equal { word = "" } complete_word(word, completions, only_args_allowed, expecting_arg_for, arg_num) } else { if expecting_arg_for != nil { - if completions.split_on_equals && word == "=" { + if is_option_equal { continue } expecting_arg_for = nil