about summary refs log tree commit diff
path: root/Completion/Zsh/Type/_vars
blob: 0f97d6cdaa5872df722e94c2fb8e7657203c917f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#compdef getopts unset

# This will handle completion of keys of associative arrays, e.g. at
# `vared foo[<TAB>'.

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