From 4bf4818f5a4ffc04f98c796c8b44dd7472fc771b Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Fri, 5 Oct 2001 11:56:56 +0000 Subject: make _cd use only one call to _alternative, including completions from _tilde (using the named-directories tag) (15945) --- Completion/Zsh/Command/_cd | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Completion/Zsh') diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 3a536cb7b..384fe2d66 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -32,13 +32,17 @@ else fi if [[ $PREFIX != (\~|/|./|../)* ]]; then - local tmpcdpath + local tmpcdpath alt + tmpcdpath=(${${(@)cdpath:#.}:#$PWD}) + (( $#tmpcdpath )) && + alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) + # With cdablevars, we can complete foo as if ~foo/ if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then if [[ "$PREFIX" != */* ]]; then - _tilde && ret=0 + alt=( "$alt[@]" 'named-directories: : _tilde' ) else local oipre="$IPREFIX" opre="$PREFIX" dirpre dir @@ -51,26 +55,22 @@ else PREFIX="${PREFIX#*/}" [[ $#dir -eq 1 && "$dir[1]" != "~$dirpre" ]] && - _wanted named-directories expl 'directories after cdablevar' \ + _wanted named-directories expl 'directory after cdablevar' \ _path_files -W dir -/ && ret=0 PREFIX="$opre" IPREFIX="$oipre" fi fi - if [[ $#tmpcdpath -ne 0 ]]; then - # Don't complete local directories in command position, that's - # already handled by _command_names (see _autocd) - if [[ CURRENT -eq 1 ]]; then - _wanted path-directories expl 'directories in cdpath' \ - _path_files -W tmpcdpath -/ && ret=0 - else - _alternative \ - 'local-directories:local directories:_path_files -/' \ - "path-directories:directories in cdpath:_path_files -W tmpcdpath -/" && ret=0 - fi - return ret - fi + # Don't complete local directories in command position, that's + # already handled by _command_names (see _autocd) + + [[ CURRENT -ne 1 ]] && + alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" ) + + _alternative "$alt[@]" && ret=0 + + return ret fi _wanted directories expl directory _path_files -/ && ret=0 -- cgit 1.4.1