about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-15 09:06:21 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-15 09:06:21 +0000
commit818cba3dbfb01030680237d248caaf2e9c3e5ac3 (patch)
tree44f04ea396616e2d92896749a8d3e41727e9d7c9 /Completion
parent20789f5f92c9a70388af947691357bbb497a7a42 (diff)
downloadzsh-818cba3dbfb01030680237d248caaf2e9c3e5ac3.tar.gz
zsh-818cba3dbfb01030680237d248caaf2e9c3e5ac3.tar.xz
zsh-818cba3dbfb01030680237d248caaf2e9c3e5ac3.zip
make _files try each pattern only once (and stop after `*') (11915)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_files11
1 files changed, 9 insertions, 2 deletions
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