1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-20 14:04:03 +01:00
zsh/Completion/Builtins/_vars

34 lines
716 B
Plaintext

#compdef getopts unset vared
# This will handle completion of keys of associative arrays, e.g. at
# `vared foo[<TAB>'.
local ret=1
if [[ $PREFIX = *\[* ]]; then
local var=${PREFIX%%\[*}
local elt="${PREFIX#*\]}${SUFFIX%\]}"
local addclose
compset -p $(( ${#var} + 1 ))
if ! compset -S \]; then
addclose=(-S "${${QIPREFIX:+]}:-\]}")
fi
if [[ ${(tP)var} = assoc* ]]; then
local expl
_wanted -C subscript association-keys expl 'association key' \
compadd $addclose -k "$var"
fi
else
_parameters -g '^a*' "$@" && ret=0
if compset -S '\[*'; then
set - -S "" "$@"
else
set - -qS"${${QIPREFIX:+[}:-\[}" "$@"
fi
_parameters -g 'a*' "$@" && ret=0
return ret
fi