about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_brace_parameter2
-rw-r--r--Completion/Base/_vars19
2 files changed, 20 insertions, 1 deletions
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index f688e175a..5993aecba 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -16,4 +16,6 @@ ls="$RBUFFER[${#SUFFIX}+1,-1]"
 n=${(M)#ls##\"#}
 q=${(M)lp%%\"#}
 
+[[ n -gt 0 ]] && suf=''
+
 _parameters -s "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/'
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