From 25ca4f8792b99cc127f04ad059e0c66cb6e0face Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Wed, 7 Jun 2000 11:21:42 +0000 Subject: optimise command lookup in old and new completion (user/3124) --- Completion/Core/_normal | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'Completion/Core/_normal') 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*) ]] && -- cgit 1.4.1