blob: 71fa9fc9a7734d3ea6e9924191221fb312a0d247 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#autoload
local -a match=() mbegin=() mend=() # `zstyle` for some reason assigns these.
unset MENUSELECT 'compstate[list]'
compstate[insert]=
local -P key_name=
case $KEYS in
( $'\t' ) key_name=tab ;;
( $terminfo[kcbt] ) key_name=shift-tab ;;
esac
local widget_style=
builtin zstyle -s :autocomplete:${key_name}: widget-style widget_style ||
widget_style=menu-select
if [[ -n $_autocomplete__unambiguous ]] &&
builtin zstyle -t ":autocomplete:${key_name}:" insert-unambiguous; then
[[ $widget_style == (|*-)menu-* ]] &&
compstate[insert]='automenu-'
compstate[insert]+=unambiguous
unset _autocomplete__unambiguous
return
fi
local -Pi nmatches=0
if [[ $compstate[old_list] == keep ]]; then
nmatches=$_lastcomp[nmatches]
else
nmatches=$compstate[nmatches]
fi
if (( nmatches > 1 )); then
if [[ $widget_style == (|*-)menu-select ]]; then
typeset -gHi MENUSELECT=0
compstate[insert]='menu:'
# Determine which terminal line we're on (for async completion).
typeset -gHi _autocomplete__buffer_start_line=$((
max( min( _autocomplete__buffer_start_line, LINES - compstate[list_lines] ), BUFFERLINES )
))
elif [[ $compstate[old_list] != keep && $_lastcomp[insert] != (|*-)unambiguous ]]; then
compstate[list]='list force'
return
elif [[ $widget_style == (|*-)menu-complete ]]; then
compstate[insert]='menu:'
fi
fi
if [[ $key_name == shift-tab ]]; then
compstate[insert]+='0'
else
compstate[insert]+='1'
fi
if [[ $RBUFFER != [[:space:]]* ]]; then
local -a spacetags=()
builtin zstyle -a :autocomplete: add-space spacetags ||
spacetags=( executables aliases functions builtins reserved-words commands )
local -Pa comptags=()
if [[ $compstate[old_list] == keep ]]; then
comptags=( $=_lastcomp[tags] )
else
comptags=( $=_comp_tags )
fi
[[ -n ${comptags:*spacetags} ]] &&
compstate[insert]+=' '
fi
|