summaryrefslogtreecommitdiff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/Completer/_complete6
-rw-r--r--Completion/Base/Core/_dispatch49
-rw-r--r--Completion/Base/Core/_normal5
-rw-r--r--Completion/Base/Utility/_set_command14
4 files changed, 29 insertions, 45 deletions
diff --git a/Completion/Base/Completer/_complete b/Completion/Base/Completer/_complete
index 23670f7c0..743fd046b 100644
--- a/Completion/Base/Completer/_complete
+++ b/Completion/Base/Completer/_complete
@@ -95,7 +95,7 @@ fi
comp="$_comps[-first-]"
if [[ -n "$comp" ]]; then
- service="${_servicecomps[-first-]:--first-}"
+ service="${_services[-first-]:--first-}"
ccarray[3]=-first-
eval "$comp" && ret=0
if [[ "$_compskip" = all ]]; then
@@ -124,7 +124,7 @@ else
ccarray[3]="$cname"
comp="$_comps[$cname]"
- service="${_servicecomps[$cname]:-$cname}"
+ service="${_services[$cname]:-$cname}"
# If not, we use default completion, if any.
@@ -134,7 +134,7 @@ else
return 1
fi
comp="$_comps[-default-]"
- service="${_servicecomps[-default-]:--default-}"
+ service="${_services[-default-]:--default-}"
fi
[[ -n "$comp" ]] && eval "$comp" && ret=0
fi
diff --git a/Completion/Base/Core/_dispatch b/Completion/Base/Core/_dispatch
index 124aea112..cd6a87171 100644
--- a/Completion/Base/Core/_dispatch
+++ b/Completion/Base/Core/_dispatch
@@ -1,31 +1,17 @@
#autoload
local comp pat val name i ret=1 _compskip="$_compskip"
-local curcontext="$curcontext" service str comptype noskip def
-local __comps __patcomps __postpatcomps __services
+local curcontext="$curcontext" service str noskip
# If we get the option `-s', we don't reset `_compskip'.
-while [[ "$1" = -[sd] ]]; do
- if [[ "$1" = -s ]]; then
- noskip=yes
- else
- def=yes
- fi
- shift
-done
+if [[ "$1" = -s ]]; then
+ noskip=yes
+fi
[[ -z "$noskip" ]] && _compskip=
-comptype=$1
-
-__comps=_$1
-
-(( ${(P)+__comps} )) || return 1
-
-__patcomps=_pat$1
-__postpatcomps=_postpat$1
-__services=_service$1
+curcontext="${curcontext%:*:*}:${1}:"
shift
@@ -35,9 +21,9 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
for str in "$@"; do
[[ -n "$str" ]] || continue
- service="${${(e):-\$${__services}[\$str]}:-$str}"
- for i in "${(@e):-\$${__patcomps}[(K)\$str]}"; do
- "$i" && ret=0
+ service="${_services[$str]:-$str}"
+ for i in "${(@)_patcomps[(K)$str]}"; do
+ eval "$i" && ret=0
if [[ "$_compskip" = *patterns* ]]; then
break
elif [[ "$_compskip" = all ]]; then
@@ -54,30 +40,27 @@ ret=1
for str in "$@"; do
[[ -n "$str" ]] || continue
name="$str"
- comp="${(e):-\$${__comps}[\$str]}"
- service="${${(e):-\$${__services}[\$str]}:-$str}"
+ comp="${_comps[$str]}"
+ service="${_services[$str]:-$str}"
[[ -z "$comp" ]] || break
done
# And generate the matches, probably using default completion.
-if [[ -n "$comp" ]]; then
+if [[ -n "$comp" && "$name" != "${argv[-1]}" ]]; then
_compskip=patterns
eval "$comp" && ret=0
[[ "$_compskip" = (all|*patterns*) ]] && return ret
-elif [[ "$_compskip" != *default* ]]; then
- name=-default-
- comp="${(e):-\$${__comps}[-default-]}"
fi
if [[ "$_compskip" != (all|*patterns*) ]]; then
for str; do
[[ -n "$str" ]] || continue
- service="${${(e):-\$${__services}[\$str]}:-$str}"
- for i in "${(@e):-\$${__postpatcomps}[(K)\$str]}"; do
+ service="${_services[$str]:-$str}"
+ for i in "${(@)_postpatcomps[(K)$str]}"; do
_compskip=default
- "$i" && ret=0
+ eval "$i" && ret=0
if [[ "$_compskip" = *patterns* ]]; then
break
elif [[ "$_compskip" = all ]]; then
@@ -88,9 +71,9 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
done
fi
-[[ "$name" = -default- && -n "$comp" &&
+[[ "$name" = "${argv[-1]}" && -n "$comp" &&
"$_compskip" != (all|*default*) ]] &&
- service="${${(e):-\$${__services}[-default-]}:--default-}" &&
+ service="${_services[$name]:-$name}" &&
eval "$comp" && ret=0
_compskip=''
diff --git a/Completion/Base/Core/_normal b/Completion/Base/Core/_normal
index 028687fd1..36ecb225d 100644
--- a/Completion/Base/Core/_normal
+++ b/Completion/Base/Core/_normal
@@ -1,6 +1,6 @@
#compdef -command-line-
-local _comp_command1 _comp_command2 skip
+local _comp_command1 _comp_command2 _comp_command skip
if [[ "$1" = -s ]]; then
skip=(-s)
@@ -22,4 +22,5 @@ fi
_set_command
-_dispatch -d "$skip[@]" comps "$_comp_command1" "$_comp_command2"
+_dispatch "$skip[@]" "$_comp_command" \
+ "$_comp_command1" "$_comp_command2" -default-
diff --git a/Completion/Base/Utility/_set_command b/Completion/Base/Utility/_set_command
index daf532686..6b4910889 100644
--- a/Completion/Base/Utility/_set_command
+++ b/Completion/Base/Utility/_set_command
@@ -1,7 +1,7 @@
#autoload
-# This sets the parameters _comp_command1 and _comp_command2 in the
-# calling function.
+# This sets the parameters _comp_command1, _comp_command2 and _comp_command
+# in the calling function.
local command
@@ -11,21 +11,21 @@ command="$words[1]"
if (( $+builtins[$command] + $+functions[$command] )); then
_comp_command1="$command"
- curcontext="${curcontext%:*:*}:${_comp_command1}:"
+ _comp_command="$_comp_command1"
elif [[ "$command[1]" = '=' ]]; then
eval _comp_command2\=$command
_comp_command1="$command[2,-1]"
- curcontext="${curcontext%:*:*}:${_comp_command2}:"
+ _comp_command="$_comp_command2"
elif [[ "$command" = ..#/* ]]; then
_comp_command1="${PWD}/$command"
_comp_command2="${command:t}"
- curcontext="${curcontext%:*:*}:${_comp_command2}:"
+ _comp_command="$_comp_command2"
elif [[ "$command" = */* ]]; then
_comp_command1="$command"
_comp_command2="${command:t}"
- curcontext="${curcontext%:*:*}:${_comp_command2}:"
+ _comp_command="$_comp_command2"
else
_comp_command1="$command"
_comp_command2="$commands[$command]"
- curcontext="${curcontext%:*:*}:${_comp_command1}:"
+ _comp_command="$_comp_command1"
fi