about summary refs log tree commit diff
path: root/Completion/Zsh/Type/_vars
blob: ec59c03be664380cffe7ac097a0d7b5fcf3d9555 (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>' could complete to `vared foo[key]'.

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