diff options
Diffstat (limited to 'Completion/Core/_files')
-rw-r--r-- | Completion/Core/_files | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/Completion/Core/_files b/Completion/Core/_files index 8a9bbfc95..a64e5c093 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -6,7 +6,7 @@ zparseopts -a opts \ '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: type="${(@j::M)${(@)tmp#-}#?}" -(( $tmp[(I)-g*] )) && glob="${(j: :)${(@M)tmp:#-g*}#-g}" +(( $tmp[(I)-g*] )) && glob="${(j:,:)${(@M)tmp:#-g*}#-g}" ign=$opts[(I)-F] if (( ign )); then ign=( $=opts[ign+1] ) @@ -20,56 +20,59 @@ else fi if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then - [[ "$type" = */* ]] && glob="$glob *(-/)" + [[ "$type" = */* ]] && glob="$glob,*(-/)" pats=() for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do if [[ $i = *[^\\]:* ]]; then - pats=( "$pats[@]" " $i" ) + pats=( "$pats[@]" " $i " ) else - pats=( "$pats[@]" " ${i}:files" ) + pats=( "$pats[@]" " ${i}:files " ) fi done else if [[ "$type" = *g* ]]; then if [[ "$type" = */* ]]; then - pats=( " ${glob//:/\\:} *(-/):globbed-files" '*:all-files' ) + pats=( " ${glob//:/\\:}:globbed-files *(-/):directories" '*:all-files ' ) else - pats=( " ${glob//:/\\:}:globbed-files" - '*(-/):directories' '*:all-files' ) + pats=( " ${glob//:/\\:}:globbed-files " + '*(-/):directories ' '*:all-files ' ) fi elif [[ "$type" = */* ]]; then - pats=( '*(-/):directories' '*:all-files' ) + pats=( '*(-/):directories ' '*:all-files ' ) else - pats=( '*:all-files' ) + pats=( '*:all-files ' ) fi fi -for def in "$pats[@]"; do ###"${(@)${(@)pats#*[^\\]:}%%:*}"; do +for def in "$pats[@]"; do + def="${def##[[:blank:]]#}" + while [[ "$def" = *[^\\][[:blank:]]* ]]; do + sdef="${(M)def#*[^\\][[:blank:]]}" + tag="${${sdef#*[^\\]:}%%:*}" + pat="${${${sdef%%:${tag}*}//\\\\:/:}//,/ }" - tag="${${def#*[^\\]:}%%:*}" - pat="${${def%%:${tag}*}//\\\\:/:}" - - if [[ "$pat" != \ # ]]; then - if [[ "$def" = *:${tag}:* ]]; then - descr="${def#*:${tag}:}" + if [[ "$sdef" = *:${tag}:* ]]; then + descr="${(Q)sdef#*:${tag}:}" else descr=file end=yes fi - fi - if _wanted "$tag"; then - _comp_ignore=() - while _next_label "$tag" expl "$descr"; do - _comp_ignore=( $_comp_ignore $ign ) - if [[ -n "$end" ]]; then - _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 - else - _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 - fi + _tags "$tag" + while _tags; do + _comp_ignore=() + while _next_label "$tag" expl "$descr"; do + _comp_ignore=( $_comp_ignore $ign ) + if [[ -n "$end" ]]; then + _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 + else + _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 + fi + done done - (( ret )) || return 0 - fi + def="${${def#${sdef}}##[[:blank:]]#}" + done + (( ret )) || return 0 done return 1 |