summaryrefslogtreecommitdiffstats
path: root/Completion/Core
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-07 11:21:42 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-07 11:21:42 +0000
commit25ca4f8792b99cc127f04ad059e0c66cb6e0face (patch)
treec9fdf61fdddd3dd9f623b09cc011b6ae2c03e233 /Completion/Core
parent11711: Andrej: diff output workaround (diff)
downloadzsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.gz
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.bz2
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.lz
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.xz
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.zst
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.zip
optimise command lookup in old and new completion (user/3124)
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_normal49
1 files changed, 28 insertions, 21 deletions
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index 52f0bb352..e0375e077 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -23,11 +23,14 @@ if [[ CURRENT -eq 1 ]]; then
return ret
else
- if [[ "$command[1]" == '=' ]]; then
+ if (( $+builtins[$command] + $+functions[$command] )); then
+ cmd1="$command"
+ curcontext="${curcontext%:*:*}:${cmd1}:"
+ elif [[ "$command[1]" = '=' ]]; then
eval cmd1\=$command
cmd2="$command[2,-1]"
curcontext="${curcontext%:*:*}:${cmd2}:"
- elif [[ "$command" == */* ]]; then
+ elif [[ "$command" = */* ]]; then
cmd1="$command"
cmd2="${command:t}"
curcontext="${curcontext%:*:*}:${cmd2}:"
@@ -50,15 +53,17 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
return ret
fi
done
- for i in "${(@)_patcomps[(K)$cmd2]}"; do
- "$i" && ret=0
- if [[ "$_compskip" = *patterns* ]]; then
- break
- elif [[ "$_compskip" = all ]]; then
- _compskip=''
- return ret
- fi
- done
+ if [[ -n "$cmd2" ]]; then
+ for i in "${(@)_patcomps[(K)$cmd2]}"; do
+ "$i" && ret=0
+ if [[ "$_compskip" = *patterns* ]]; then
+ break
+ elif [[ "$_compskip" = all ]]; then
+ _compskip=''
+ return ret
+ fi
+ done
+ fi
fi
# Now look up the two names in the normal completion array.
@@ -90,16 +95,18 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
return ret
fi
done
- for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
- _compskip=default
- "$i" && ret=0
- if [[ "$_compskip" = *patterns* ]]; then
- break
- elif [[ "$_compskip" = all ]]; then
- _compskip=''
- return ret
- fi
- done
+ if [[ -n "$cmd2" ]]; then
+ for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
+ _compskip=default
+ "$i" && ret=0
+ if [[ "$_compskip" = *patterns* ]]; then
+ break
+ elif [[ "$_compskip" = all ]]; then
+ _compskip=''
+ return ret
+ fi
+ done
+ fi
fi
[[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] &&