From bb36b80178e38adf67188a7367b88dd9de6b39db Mon Sep 17 00:00:00 2001 From: Sebastian Stark Date: Tue, 21 Feb 2023 23:12:47 +0100 Subject: 51470 (tweaked, c.f. 51476): Separate cdpath elements in path-directories completion --- Completion/Zsh/Command/_cd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Completion/Zsh/Command') 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 -- cgit 1.4.1