summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/plugins/zsh-autocomplete/functions/completion/_autocomplete.unambiguous
blob: f258a39c3519b1470c9e84508794d610b51b7a80 (plain)
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
30
31
32
33
34
35
#autoload
# setopt localoptions verbose xtrace

[[ -v _autocomplete__partial_list ]] &&
    return 1

(( compstate[nmatches] > 1 )) ||
  return 1
[[ $curcontext == history-*:* ||
    $IPREFIX$PREFIX$SUFFIX$ISUFFIX == *${compstate[unambiguous]:#?}* ]] &&
  return 1

local -P tag=unambiguous
_tags $tag
_tags ||
    return
_requested $tag ||
    return

typeset -gH _autocomplete__unambiguous="$compstate[unambiguous]"

if builtin zstyle -t :autocomplete:tab: insert-unambiguous; then
  local -Pi nxt= prv=1
  local -P subs= cols=
  for nxt in ${(s.:.)compstate[unambiguous_positions]}; do
    subs+='('${(b)compstate[unambiguous][prv,nxt]}')*'
    cols+='=30;103'  # black foreground, bright yellow background
    (( prv = ++nxt ))
  done
  ZLS_COLORS="=(#bi)*$subs=$cols:$ZLS_COLORS"
  return 1
fi

builtin compadd -J "$tag" \
    -x $'%{\e[0;2m%}common substring:%b %F{0}%K{11}'"$compstate[unambiguous]%f%k"