Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] _subscript: fix the completion of associative array keys



On 01/26/2016 01:49 AM, Eric Cook wrote:
> iirc the way ${(P)var} works was changed/"fix"(?) recently, but i can't find
> the thread now so i may be wrong. But currently: $options[<tab>
> completes values not the keys.

Now without empty argument removal: typeset -A foo; foo=('' bar) # is legal.
diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript
index 0ccc0c4..679f129 100644
--- a/Completion/Zsh/Context/_subscript
+++ b/Completion/Zsh/Context/_subscript
@@ -81,8 +81,8 @@ elif compset -P '\('; then
 elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
   local suf MATCH MBEGIN MEND
   local -a keys
-  keys=(${${(kP)compstate[parameter]}//(#m)[\$\\\[\]\(\)\[\{\}]/\\$MATCH})
-  keys=(${keys//#%(#m)[*@]/(e)$MATCH})
+  keys=("${(@)${(@k)${(P)compstate[parameter]}}//(#m)[\$\\\[\]\(\)\[\{\}]/\\$MATCH}")
+  keys=("${(@)keys//#%(#m)[*@]/(e)$MATCH}")
   [[ "$RBUFFER" != (|\\)\]* ]] && suf="$osuf"

   _wanted association-keys expl 'association key' \



Messages sorted by: Reverse Date, Date, Thread, Author