1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

48864: Improve extra-verbose completion display strings for array parameter values

This commit is contained in:
Marlon Richert 2021-05-17 14:49:02 +03:00 committed by Oliver Kiddle
parent a23f19bfbd
commit e732073415
3 changed files with 23 additions and 10 deletions

View file

@ -1,3 +1,8 @@
2021-05-21 Oliver Kiddle <opk@zsh.org>
* Marlon Richert: 48864: Completion/Zsh/Type/_parameters: Improve
extra-verbose completion display strings for array parameter values
2021-05-18 Daniel Shahaf <d.s@daniel.shahaf.name> 2021-05-18 Daniel Shahaf <d.s@daniel.shahaf.name>
* 48601/0005: Functions/Misc/zmathfuncdef: Fix the workers/48147 * 48601/0005: Functions/Misc/zmathfuncdef: Fix the workers/48147

View file

@ -11,9 +11,9 @@ if compset -P '*:'; then
return return
fi fi
local MATCH i pfilt local i pfilt
local -i MBEGIN MEND nm=$compstate[nmatches] local -i nm=$compstate[nmatches]
local -a expl pattern=(-g \*) normal described verbose faked fakes tmp local -a expl pattern=( -g \* ) normal described verbose faked fakes tmp
zstyle -t ":completion:${curcontext}:parameters" prefix-needed && zstyle -t ":completion:${curcontext}:parameters" prefix-needed &&
[[ $PREFIX != [_.]* ]] && [[ $PREFIX != [_.]* ]] &&
@ -27,8 +27,13 @@ if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then
) )
compadd "$@" "$expl[@]" -D described -a - described compadd "$@" "$expl[@]" -D described -a - described
if (( $#described )); then 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=( verbose=(
${described[@]:/(#m)*/"${MATCH}:${(@q+)${(Pkv@q+)MATCH}//\\/\\\\}"} ) ${${${(f@)"$( typeset -m ${(@b)described} )"}/=/:}[@]//'\'/'\\'}
)
_describe -t parameters parameter verbose "$@" "$expl[@]" _describe -t parameters parameter verbose "$@" "$expl[@]"
fi fi
@ -52,4 +57,3 @@ compadd "$@" "$expl[@]" - "$normal[@]" "${(@)fakes:|described}" \
"${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}" "${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}"
(( compstate[nmatches] > nm )) (( compstate[nmatches] > nm ))
return 0

View file

@ -255,15 +255,18 @@ F:regression test workers/31611
>FI:{file1} >FI:{file1}
>FI:{file2} >FI:{file2}
comptesteval "bar=({$'\\0'..$'\\C-?'}); baz=\$bar" comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})"
comptesteval 'typeset -A bat=( "$bar[@]" )'
comptesteval 'typeset bay="$bar"'
comptesteval 'zstyle ":completion:*:parameters" extra-verbose yes' comptesteval 'zstyle ":completion:*:parameters" extra-verbose yes'
comptesteval 'zstyle ":completion:*" fake-parameters bar baz:array' comptesteval 'zstyle ":completion:*" fake-parameters bar bat bay'
comptest $': $ba\t' comptest $': $ba\t'
0:extra-verbose shows parameter values 0:extra-verbose shows parameter values
>line: {: $ba}{} >line: {: $ba}{}
>DESCRIPTION:{parameter} >DESCRIPTION:{parameter}
>NO:{bar -- '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '^M} >NO:{bar -- ( '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '}
>NO:{baz -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^} >NO:{bat -- ( [' ']='!' ['"']='#' ['$']=% ['&']=\' ['(']=')' ['*']=+ [,]=- [.]=/}
>NO:{bay -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}
comptesteval "path=( $ZTST_srcdir:A )" comptesteval "path=( $ZTST_srcdir:A )"
comptesteval 'typeset -H paths=HIDDEN' comptesteval 'typeset -H paths=HIDDEN'
@ -280,7 +283,8 @@ F:regression test workers/31611
>line: {: $ba}{} >line: {: $ba}{}
>DESCRIPTION:{parameter} >DESCRIPTION:{parameter}
>NO:{bar} >NO:{bar}
>NO:{baz} >NO:{bat}
>NO:{bay}
comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }' comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }'
comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }' comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }'