about summary refs log tree commit diff
path: root/Completion/Core/_prefix
blob: 34decf4254e7e5f4153a892496b5513fae836b03 (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
26
27
28
29
#autoload

# Try to ignore the suffix. A bit like e-o-c-prefix.

[[ -n "$SUFFIX" ]] || return 1

local curcontext="${curcontext/:[^:]#:/:prefix-${(M)#${(@)_completers[1,-$#_completers_left]}:#_prefix}:}" comp i

zstyle -a ":completion:${curcontext}:" completer comp ||
  comp=( "${(@)_completers[1,-${#_completers_left}-1][(R)_prefix,-1]}" )

if zstyle -t ":completion:${curcontext}:" add-space; then
  ISUFFIX=" $SUFFIX"
else
  ISUFFIX="$SUFFIX"
fi
SUFFIX=''

local _completers _completer_left

_completers=( "$comp[@]" )
_completers_left=( "$comp[@]" )

for i in "$comp[@]"; do
  [[ "$i" != _prefix ]] && "$i" && return 0
  shift 1 _completers_left
done

return 1