aboutsummaryrefslogtreecommitdiff
path: root/Completion/Base/_vars
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base/_vars')
-rw-r--r--Completion/Base/_vars19
1 files changed, 18 insertions, 1 deletions
diff --git a/Completion/Base/_vars b/Completion/Base/_vars
index f06562694..a40df7699 100644
--- a/Completion/Base/_vars
+++ b/Completion/Base/_vars
@@ -1,3 +1,20 @@
#compdef getopts read unset vared
-compgen -v
+# 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
+ compadd $addclose - ${(kP)var}
+ fi
+else
+ compgen -v
+fi