about summary refs log tree commit diff
path: root/Completion/Unix/Type/_path_files
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type/_path_files')
-rw-r--r--Completion/Unix/Type/_path_files15
1 files changed, 13 insertions, 2 deletions
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index a8d03efa9..a170983ba 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -438,8 +438,19 @@ for prepath in "$prepaths[@]"; do
 
     tmp2=( "$tmp1[@]" )
 
-    if [[ "$tpre$tsuf" = (#b)*/(*) && -n "$fake${match[1]}" ]]; then
-      compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
+    if [[ "$tpre$tsuf" = (#b)*/(*) ]]; then
+
+      # We are going to be looping over the leading path segments.
+      # This means we should not apply special-dirs handling unless
+      # the path tail is a fake directory that needs to be simulated,
+      # and we should not apply pattern matching until we are looking
+      # for files rather than for intermediate directories.
+
+      if [[ -n "$fake${match[1]}" ]]; then
+        compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
+      else
+        compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" '' fake
+      fi
     elif [[ "$sopt" = *[/f]* ]]; then
       compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake "$pats[@]"
     else