From 01fa693061d3cb414758767925a1540a3adf7668 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Mon, 2 Apr 2001 11:19:13 +0000 Subject: [PATCH] moved from Completion/Builtins/_vars --- Completion/Zsh/Type/_vars | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Completion/Zsh/Type/_vars diff --git a/Completion/Zsh/Type/_vars b/Completion/Zsh/Type/_vars new file mode 100644 index 000000000..dece0fecb --- /dev/null +++ b/Completion/Zsh/Type/_vars @@ -0,0 +1,25 @@ +#compdef getopts unset vared + +# This will handle completion of keys of associative arrays, e.g. at +# `vared foo['. + +local ret=1 + +if [[ $PREFIX = *\[* ]]; then + compstate[parameter]=${PREFIX%%(|\\)\[*} + + IPREFIX=${PREFIX%%\[*}\[ + PREFIX=${PREFIX#*\[} + + _subscript -q +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