From 818cba3dbfb01030680237d248caaf2e9c3e5ac3 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 15 Jun 2000 09:06:21 +0000 Subject: make _files try each pattern only once (and stop after `*') (11915) --- Completion/Core/_files | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Completion') diff --git a/Completion/Core/_files b/Completion/Core/_files index 391d570a5..96bdbe0e7 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -1,6 +1,6 @@ #autoload -local opts tmp glob pat pats expl tag i def descr end ign ret=1 match +local opts tmp glob pat pats expl tag i def descr end ign ret=1 match tried zparseopts -a opts \ '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: @@ -26,7 +26,8 @@ fi if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then [[ "$type" = */* ]] && glob="$glob,*(-/)" pats=() - for i in ${tmp//%p/${${glob:-\*}//:/\\:} }; do + + for i in ${tmp//%p/${${glob:-\*}//:/\\:}}; do if [[ $i = *[^\\]:* ]]; then pats=( "$pats[@]" " $i " ) else @@ -48,6 +49,7 @@ else fi fi +tried=() for def in "$pats[@]"; do eval "def=( ${${def:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )" for sdef in "$def[@]"; do @@ -55,6 +57,10 @@ for def in "$pats[@]"; do tag="${${sdef#*[^\\]:}%%:*}" pat="${${${sdef%%:${tag}*}//\\:/:}//,/ }" + (( $tried[(I)${(q)pat}] )) && continue + + tried=( "$tried[@]" "$pat" ) + if [[ "$sdef" = *:${tag}:* ]]; then descr="${(Q)sdef#*:${tag}:}" else @@ -75,6 +81,7 @@ for def in "$pats[@]"; do done (( ret )) || break done + [[ "$pat" = '*' ]] && return ret done (( ret )) || return 0 done -- cgit 1.4.1