diff options
author | Marlon Richert <marlon.richert@gmail.com> | 2021-05-17 14:49:02 +0300 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2021-05-21 23:45:26 +0200 |
commit | e7320734153829e8bc94c1255bdeba724e13e8b6 (patch) | |
tree | cbf3731280b324b35da76b276457ae207299476f /Completion | |
parent | a23f19bfbd8c4d7e0a452232659b733bf882474f (diff) | |
download | zsh-e7320734153829e8bc94c1255bdeba724e13e8b6.tar.gz zsh-e7320734153829e8bc94c1255bdeba724e13e8b6.tar.xz zsh-e7320734153829e8bc94c1255bdeba724e13e8b6.zip |
48864: Improve extra-verbose completion display strings for array parameter values
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Zsh/Type/_parameters | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters index 00c181e11..b5da45c58 100644 --- a/Completion/Zsh/Type/_parameters +++ b/Completion/Zsh/Type/_parameters @@ -11,9 +11,9 @@ if compset -P '*:'; then return fi -local MATCH i pfilt -local -i MBEGIN MEND nm=$compstate[nmatches] -local -a expl pattern=(-g \*) normal described verbose faked fakes tmp +local i pfilt +local -i nm=$compstate[nmatches] +local -a expl pattern=( -g \* ) normal described verbose faked fakes tmp zstyle -t ":completion:${curcontext}:parameters" prefix-needed && [[ $PREFIX != [_.]* ]] && @@ -27,8 +27,13 @@ if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then ) compadd "$@" "$expl[@]" -D described -a - described if (( $#described )); then + # Normally, calling typeset without flags would print the values of its + # arguments. However, inside a function, it instead declare its arguments + # as local variables and outputs nothing. Thus, to force it print out + # parameter values, we pass it the -m flag. verbose=( - ${described[@]:/(#m)*/"${MATCH}:${(@q+)${(Pkv@q+)MATCH}//\\/\\\\}"} ) + ${${${(f@)"$( typeset -m ${(@b)described} )"}/=/:}[@]//'\'/'\\'} + ) _describe -t parameters parameter verbose "$@" "$expl[@]" fi @@ -52,4 +57,3 @@ compadd "$@" "$expl[@]" - "$normal[@]" "${(@)fakes:|described}" \ "${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}" (( compstate[nmatches] > nm )) -return 0 |