From 8ea597722287a9a2f827f754364491bb5f033c15 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 12 Nov 2021 20:41:04 +0100 Subject: 49564: always use descriptions included in the file-patterns style and allow the recursive-files style to also work in those cases --- Completion/Unix/Type/_files | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'Completion/Unix/Type') diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files index 4ddec1e12..f03b4a148 100644 --- a/Completion/Unix/Type/_files +++ b/Completion/Unix/Type/_files @@ -92,7 +92,10 @@ for def in "$pats[@]"; do pat="${${sdef%%:${tag}*}//\\:/:}" if [[ "$sdef" = *:${tag}:* ]]; then + # If the file-patterns spec includes a description, use it and give the + # group/description options from it precedence over passed in parameters. descr="${(Q)sdef#*:${tag}:}" + end= else if (( $opts[(I)-X] )); then descr= @@ -108,26 +111,30 @@ for def in "$pats[@]"; do while _next_label "$tag" expl "$descr"; do _comp_ignore=( $_comp_ignore $ign ) if [[ -n "$end" ]]; then - if _path_files -g "$pat" "$opts[@]" "$expl[@]"; then - ret=0 - elif [[ $PREFIX$SUFFIX != */* ]] && zstyle -a ":completion:${curcontext}:$tag" recursive-files rfiles; then - for rfile in $rfiles; do - if [[ $PWD/ = ${~rfile} ]]; then - if [[ -z $subtree ]]; then - subtree=( **/*(/) ) - fi - for prepath in $subtree; do - oprefix=$PREFIX - PREFIX=$prepath/$PREFIX - _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 - PREFIX=$oprefix - done - break - fi - done - fi + expl=( "$opts[@]" "$expl[@]" ) else - _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 + expl+=( "$opts[@]" ) + fi + + if _path_files -g "$pat" "$expl[@]"; then + ret=0 + elif [[ $PREFIX$SUFFIX != */* ]] && \ + zstyle -a ":completion:${curcontext}:$tag" recursive-files rfiles + then + for rfile in $rfiles; do + if [[ $PWD/ = ${~rfile} ]]; then + if [[ -z $subtree ]]; then + subtree=( **/*(/) ) + fi + for prepath in $subtree; do + oprefix=$PREFIX + PREFIX=$prepath/$PREFIX + _path_files -g "$pat" "$expl[@]" && ret=0 + PREFIX=$oprefix + done + break + fi + done fi done (( ret )) || break -- cgit 1.4.1