summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Type/_path_files23
1 files changed, 23 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index e75e81efd..fc0789f01 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -318,6 +318,29 @@ for prepath in "$prepaths[@]"; do
 
   skipped=
   cpre=
+
+  if zstyle -t ":completion:${curcontext}:paths" accept-exact-dirs &&
+    [[ $pre = (#b)(*)/([^/]#) ]]; then
+    # We've been told that we can accept an exact directory
+    # prefix immediately.  Try this with the longest path prefix
+    # first:  this saves stats in the simple case and may get around
+    # automount behaviour if early components don't yet exist.
+    tmp1=$match[1]
+    tpre=$match[2]
+    while true; do
+      if [[ -d $donepath$tmp1 ]]; then
+	donepath=$donepath$tmp1/
+	pre=$tpre
+	break
+      elif [[ $tmp1 = (#b)(*)/([^/]#) ]]; then
+	tmp1=$match[1]
+	tpre=$match[2]/$tpre
+      else
+	break
+      fi
+    done
+  fi
+
   tpre="$pre"
   tsuf="$suf"
   testpath="$donepath"