From cd6fd2b0a3641774e7854ff8298d1d82643c4b4a Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Tue, 7 May 2019 23:24:49 +0200 Subject: 44274: allow finer control of completion match soring with compadd's -o option --- Completion/Base/Core/_description | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'Completion/Base/Core/_description') diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description index 304c747a6..c2a0e080b 100644 --- a/Completion/Base/Core/_description +++ b/Completion/Base/Core/_description @@ -1,13 +1,13 @@ #autoload -local name gropt nopt xopt format gname hidden hide match opts tag sort +local name nopt xopt format gname hidden hide match opts tag +local -a gropt sort opts=() -gropt=(-J) xopt=(-X) nopt=() -zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt +zparseopts -K -D -a nopt 1 2 V=gropt J x=xopt 3="${${3##[[:blank:]]#}%%[[:blank:]]#}" [[ -n "$3" ]] && _lastdescr=( "$_lastdescr[@]" "$3" ) @@ -33,14 +33,18 @@ zstyle -s ":completion:${curcontext}:$1" matcher match && # Use sort style, but ignore `menu' value to help _expand. # Also don't override explicit use of -V. -if { zstyle -s ":completion:${curcontext}:$1" sort sort || - zstyle -s ":completion:${curcontext}:" sort sort; } && - [[ "$gropt" = -J && $sort != menu ]]; then - if [[ "$sort" = (yes|true|1|on) ]]; then - gropt=(-J) - else - gropt=(-V) +if [[ -z "$gropt" ]]; then + if zstyle -a ":completion:${curcontext}:$1" sort sort || + zstyle -a ":completion:${curcontext}:" sort sort + then + if [[ -z "${(@)sort:#(match|numeric|reverse)}" ]]; then + gropt=( -o ${(j.,.)sort} ) + elif [[ "$sort" != (yes|true|1|on|menu) ]]; then + gropt=( -o nosort ) fi + fi +else + gropt=( -o nosort ) fi if [[ -z "$_comp_no_ignore" ]]; then @@ -79,15 +83,15 @@ fi if [[ -n "$gname" ]]; then if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" fi else if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- fi fi -- cgit 1.4.1