about summary refs log tree commit diff
path: root/Completion/Core/_files
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core/_files')
-rw-r--r--Completion/Core/_files31
1 files changed, 25 insertions, 6 deletions
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 1755abebd..f16da0b50 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -1,12 +1,23 @@
 #autoload
 
-local opts tmp glob pats expl tag i pat descr minus
+local opts tmp glob pats expl tag i pat descr end ign ret=1
 
 zparseopts -a opts \
     '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
 
 type="${(@j::M)${(@)tmp#-}#?}"
 (( $tmp[(I)-g*] )) && glob="${(j: :)${(M)tmp:#-g*}#-g}"
+ign=$opts[(I)-F]
+if (( ign )); then
+  ign=( $=opts[ign+1] )
+  if [[ $ign = _comp_ignore ]]; then
+    ign=( $_comp_ignore )
+  else
+    opts[tmp+1]=_comp_ignore
+  fi
+else
+  ign=
+fi
 
 if zstyle -a ":completion:${curcontext}:" file-patterns pats; then
   [[ "$type" = */* ]] && glob="$glob *(-/)"
@@ -34,16 +45,24 @@ for tag in "${(@)${(@)pats#*[^\\]:}%%:*}"; do
   if [[ i -gt 0 && "$pat" != \ # ]]; then
     if [[ "$pats[i]" = *:${tag}:* ]]; then
       descr="${pats[i]#*:${tag}:}"
-      minus=()
     else
       descr=file
-      minus=(-)
+      end=yes
     fi
   fi
 
-  _wanted "$tag" expl "$descr" \
-      _path_files -g "$pat" "$opts[@]" "$minus[@]" && return 0
-
+  if _wanted "$tag"; then
+    _comp_ignore=()
+    while _next_label "$tag" expl "$descr"; do
+      _comp_ignore=( $_comp_ignored $ign )
+      if [[ -n "$end" ]]; then
+        _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0
+      else
+        _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0
+      fi
+    done
+    (( ret )) || return 0
+  fi
 done
 
 return 1