about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSebastian Stark <sstark+zsh@mailbox.org>2023-02-21 23:12:47 +0100
committerOliver Kiddle <opk@zsh.org>2023-02-24 14:40:38 +0100
commitbb36b80178e38adf67188a7367b88dd9de6b39db (patch)
tree2f1fc8b1247177b104bd5f5da370c7dc8477a5eb
parentf604645d06d03a43de8c0c7192be0fda59c26758 (diff)
downloadzsh-bb36b80178e38adf67188a7367b88dd9de6b39db.tar.gz
zsh-bb36b80178e38adf67188a7367b88dd9de6b39db.tar.xz
zsh-bb36b80178e38adf67188a7367b88dd9de6b39db.zip
51470 (tweaked, c.f. 51476): Separate cdpath elements in path-directories completion
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Zsh/Command/_cd11
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 204e64365..1897e2fa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-02-24  Oliver Kiddle  <opk@zsh.org>
 
+	* Sebastian Stark: 51470 (tweaked, c.f. 51476):
+	Completion/Zsh/Command/_cd: Separate cdpath elements in
+	path-directories completion
+
 	* 51474: Completion/Unix/Command/_ansible: make -e and --vault-id
 	options repeatable and update for new options to ansible 2.13.2
 
diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
index 46237e73d..961d121e0 100644
--- a/Completion/Zsh/Command/_cd
+++ b/Completion/Zsh/Command/_cd
@@ -70,8 +70,15 @@ else
 
     tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
 
-    (( $#tmpcdpath )) &&
-      alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' )
+    if zstyle -t ":completion:${curcontext}:path-directories" separate-sections; then
+      local elem
+      for ((elem=1; elem <= $#tmpcdpath; elem++)); do
+        alt+=( "path-directories-$elem:directory in $tmpcdpath[$elem]:_path_files -W 'tmpcdpath[$elem]' -/" )
+      done
+    else
+      (( $#tmpcdpath )) &&
+        alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' )
+    fi
 
     # With cdablevars, we can complete foo as if ~foo/
     if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then