about summary refs log tree commit diff
path: root/Completion/Base/_brace_parameter
blob: 9dfe46bd6d294b0d4c8908993383ef9d813f0ee1 (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
#compdef -brace-parameter-

setopt localoptions extendedglob

local lp ls n q suf=''

if [[ "$SUFFIX" = *\}* ]]; then
  ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
  SUFFIX="${SUFFIX%%\}*}"
elif [[ "$LBUFFER" = *\$\{[^}]#\$\{[^}]#$PREFIX ]]; then
  suf='}'
else
  suf='} '
fi

lp="$LBUFFER[1,-${#PREFIX}-1]"
ls="$RBUFFER[${#SUFFIX}+1,-1]"
n=${(M)#ls##\"#}
q=${(M)lp%%\"#}

[[ n -gt 0 ]] && suf=''

_parameters -Qs "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/}'