about summary refs log tree commit diff
path: root/Completion/Unix/Type/_path_files
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-04-14 09:57:47 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-04-14 09:57:47 +0000
commite694590b37dc59ad2dd1b417a0649aa6709bfbb4 (patch)
tree60c7b50c62b3a25770d227cef0f56553eb47724a /Completion/Unix/Type/_path_files
parentc30b038a422cb918f5a80115ef9c1541cedf3dea (diff)
downloadzsh-e694590b37dc59ad2dd1b417a0649aa6709bfbb4.tar.gz
zsh-e694590b37dc59ad2dd1b417a0649aa6709bfbb4.tar.xz
zsh-e694590b37dc59ad2dd1b417a0649aa6709bfbb4.zip
users/15011: add path-completion style
Diffstat (limited to 'Completion/Unix/Type/_path_files')
-rw-r--r--Completion/Unix/Type/_path_files21
1 files changed, 14 insertions, 7 deletions
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index acc11542d..fa02656d0 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -32,6 +32,7 @@ local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
 local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx
 local nm=$compstate[nmatches] menu matcher mopts sort mid accex fake
 local listfiles listopts tmpdisp origtmp1 Uopt
+local accept_exact_dirs path_completion
 integer npathcheck
 local -a Mopts
 
@@ -191,6 +192,11 @@ zstyle -a ":completion:${curcontext}:" fake-files fake
 
 zstyle -s ":completion:${curcontext}:" ignore-parents ignpar
 
+zstyle -t ":completion:${curcontext}:paths" accept-exact-dirs &&
+  accept_exact_dirs=1
+zstyle -T ":completion:${curcontext}:paths" path-completion &&
+  path_completion=1
+
 if [[ -n "$compstate[pattern_match]" ]]; then
   if { [[ -z "$SUFFIX" ]] && _have_glob_qual "$PREFIX" complete } ||
     _have_glob_qual "$SUFFIX" complete; then
@@ -350,16 +356,17 @@ 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.
+  if [[ ( -n $accept_exact_dirs || -z $path_completion ) && \
+        $pre = (#b)(*)/([^/]#) ]]; then
+    # We've been told either that we can accept an exact directory prefix
+    # immediately, or that path expansion is inhibited.  Try the longest
+    # path prefix first: in the first case, this saves stats in the simple
+    # case and may get around automount behaviour if early components don't
+    # yet exist, and in the second case this is the prefix we want to keep.
     tmp1=$match[1]
     tpre=$match[2]
     while true; do
-      if [[ -d $prepath$realpath$donepath$tmp1 ]]; then
+      if [[ -z $path_completion || -d $prepath$realpath$donepath$tmp1 ]]; then
 	donepath=$donepath$tmp1/
 	pre=$tpre
 	break