1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-03 17:31:33 +02:00
zsh/Completion/Builtins/_vars

34 lines
716 B
Plaintext
Raw Normal View History

#compdef getopts unset vared
1999-11-14 20:57:24 +01:00
# This will handle completion of keys of associative arrays, e.g. at
# `vared foo[<TAB>'.
local ret=1
1999-11-14 20:57:24 +01:00
if [[ $PREFIX = *\[* ]]; then
local var=${PREFIX%%\[*}
local elt="${PREFIX#*\]}${SUFFIX%\]}"
local addclose
compset -p $(( ${#var} + 1 ))
if ! compset -S \]; then
addclose=(-S "${${QIPREFIX:+]}:-\]}")
1999-11-14 20:57:24 +01:00
fi
if [[ ${(tP)var} = assoc* ]]; then
local expl
_wanted -C subscript association-keys expl 'association key' \
2000-05-31 11:38:25 +02:00
compadd $addclose -k "$var"
1999-11-14 20:57:24 +01:00
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
1999-11-14 20:57:24 +01:00
fi