{zsh,bash}-completion: use config when autocompleting profiles

We were over-enthusiastic when introducing --no-config into the
autocompletions. When autocompleting profiles, you actually need the
config, because that's where the profiles come from.

zsh is untested - I don't use it.
This commit is contained in:
Philip Langdale
2023-09-02 16:00:34 -07:00
committed by Niklas Haas
parent f3df6f53ba
commit a1c8bb2257
2 changed files with 12 additions and 3 deletions

View File

@@ -192,6 +192,7 @@ case $state in
parse-help-*)
local option_name=${state#parse-help-}
local no_config="--no-config"
# Can't do non-capturing groups without pcre, so we index the ones we want
local pattern name_group=1 desc_group=2
case $option_name in
@@ -203,6 +204,8 @@ case $state in
# but would break if a profile name contained spaces. This stricter one
# only breaks if a profile name contains tabs.
pattern=$'^\t([^\t]*)\t(.*)'
# We actually want config so we can autocomplete the user's profiles
no_config=""
;;
*)
pattern=$'^[ \t]+(--'${option_name}$'=)?([^ \t]+)[ \t]*[-:]?[ \t]*(.*)'
@@ -211,7 +214,7 @@ case $state in
esac
local -a values
local current
for current in "${(@f)$($~words[1] --no-config --${option_name}=help)}"; do
for current in "${(@f)$($~words[1] ${no_config} --${option_name}=help)}"; do
[[ $current =~ $pattern ]] || continue;
local name=${match[name_group]//:/\\:} desc=${match[desc_group]}
if [[ -n $desc ]]; then