diff options
author | Oliver Kiddle <opk@zsh.org> | 2021-11-12 20:41:04 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2021-11-12 20:41:04 +0100 |
commit | 8ea597722287a9a2f827f754364491bb5f033c15 (patch) | |
tree | 0b68668d67b356496aaa5f060a63c1cc7a30f876 /Completion | |
parent | 9bdaf0197f074b6dff70569f60c583b18e35f755 (diff) | |
download | zsh-8ea597722287a9a2f827f754364491bb5f033c15.tar.gz zsh-8ea597722287a9a2f827f754364491bb5f033c15.tar.xz zsh-8ea597722287a9a2f827f754364491bb5f033c15.zip |
49564: always use descriptions included in the file-patterns style and allow the recursive-files style to also work in those cases
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Unix/Type/_files | 45 |
1 files changed, 26 insertions, 19 deletions
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 |