mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-17 22:31:12 +01:00
zsh-workers:8631
This commit is contained in:
parent
51a999e60b
commit
b6fdcbc539
1 changed files with 28 additions and 0 deletions
28
Completion/Builtins/_vars
Normal file
28
Completion/Builtins/_vars
Normal file
|
@ -0,0 +1,28 @@
|
|||
#compdef getopts read unset vared
|
||||
|
||||
# This will handle completion of keys of associative arrays, e.g. at
|
||||
# `vared compconfig[<TAB>'. However, in this version the [ must be
|
||||
# added by hand.
|
||||
|
||||
if [[ $PREFIX = *\[* ]]; then
|
||||
local var=${PREFIX%%\[*}
|
||||
local elt="${PREFIX#*\]}${SUFFIX%\]}"
|
||||
local addclose
|
||||
|
||||
compset -p $(( ${#var} + 1 ))
|
||||
if ! compset -S \]; then
|
||||
addclose=(-S ']')
|
||||
fi
|
||||
if [[ ${(tP)var} = assoc* ]]; then
|
||||
local expl
|
||||
|
||||
_tags subscript association-keys || return 1
|
||||
|
||||
_description expl 'association key'
|
||||
compadd "$expl[@]" $addclose - ${(kP)var}
|
||||
fi
|
||||
else
|
||||
_tags any parameters || return 1
|
||||
|
||||
_parameters
|
||||
fi
|
Loading…
Reference in a new issue