1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 22:11:54 +02:00

optimise command lookup in old and new completion (user/3124)

This commit is contained in:
Sven Wischnowsky 2000-06-07 11:21:42 +00:00
parent b24757fc34
commit 25ca4f8792
3 changed files with 36 additions and 23 deletions

View file

@ -6,6 +6,9 @@
2000-06-07 Sven Wischnowsky <wischnow@zsh.org>
* user/3124: Completion/Core/_normal, Src/Zle/compctl.c: optimise
command lookup in old and new completion
* 11794: Src/Zle/compcore.c, Src/Zle/complist.c, Src/Zle/zle_tricky.c:
hopefully more consistent beeping with menu-selection

View file

@ -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*) ]] &&

View file

@ -2469,7 +2469,7 @@ makecomplistcmd(char *os, int incmd, int flags)
return ret;
}
/* This add the matches for the pattern compctls. */
/* This adds the matches for the pattern compctls. */
/**/
static int
@ -2477,9 +2477,12 @@ makecomplistpc(char *os, int incmd)
{
Patcomp pc;
Patprog pat;
char *s = findcmd(cmdstr, 1);
char *s;
int ret = 0;
s = ((shfunctab->getnode(shfunctab, cmdstr) ||
builtintab->getnode(builtintab, cmdstr)) ? NULL : findcmd(cmdstr, 1));
for (pc = patcomps; pc; pc = pc->next) {
if ((pat = patcompile(pc->pat, PAT_STATIC, NULL)) &&
(pattry(pat, cmdstr) ||