diff options
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/_arguments | 3 | ||||
-rw-r--r-- | Completion/Base/_combination | 4 | ||||
-rw-r--r-- | Completion/Base/_command_names | 2 | ||||
-rw-r--r-- | Completion/Base/_jobs | 29 | ||||
-rw-r--r-- | Completion/Base/_tilde | 4 |
5 files changed, 28 insertions, 14 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index 16293a098..5a6ee1930 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -259,7 +259,8 @@ if (( $# )) && comparguments -i "$autod" "$@"; then if [[ -z "$matched" ]] && _requested options && { ! zstyle -t ":completion${curcontext}:options" prefix-needed || - [[ "$origpre" = [-+]* ]] } ; then + [[ "$origpre" = [-+]* || + ( -z "$aret$mesg" && nm -eq compstate[nmatches] ) ]] } ; then local prevpre="$PREFIX" previpre="$IPREFIX" PREFIX="$origpre" diff --git a/Completion/Base/_combination b/Completion/Base/_combination index ffda5cae9..e7548f19f 100644 --- a/Completion/Base/_combination +++ b/Completion/Base/_combination @@ -21,7 +21,7 @@ # `_telnet' completes hosts as: # # _combination my-accounts hosts-ports-users \ -# ${options[-l]:+users=${options[-l]:q}} \ +# ${opt_args[-l]:+users=${opt_args[-l]:q}} \ # hosts "$expl[@]" # # This completes `host1', `host2', `mail-server', `news-server' and @@ -31,7 +31,7 @@ # `_telnet' completes ports as: # # _combination my-accounts hosts-ports-users \ -# ${options[-l]:+users=${options[-l]:q}} \ +# ${opt_args[-l]:+users=${opt_args[-l]:q}} \ # hosts="${line[2]:q}" \ # ports "$expl[@]" # diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names index 63c8601e9..12caf926f 100644 --- a/Completion/Base/_command_names +++ b/Completion/Base/_command_names @@ -17,11 +17,11 @@ else [[ "$1" = - ]] && shift defs=( "$defs[@]" - 'jobs:: _jobs' 'builtins:builtin command:compadd - ${(@k)builtins}' 'functions:shell function:compadd - ${(@k)functions}' 'aliases:alias:compadd - ${(@k)aliases}' 'reserved-words:reserved word:compadd - ${(@k)reswords}' + 'jobs:: _jobs -t' ) fi diff --git a/Completion/Base/_jobs b/Completion/Base/_jobs index ff9fa5a62..48d74c307 100644 --- a/Completion/Base/_jobs +++ b/Completion/Base/_jobs @@ -1,11 +1,14 @@ #autoload -local expl disp jobs job jids pfx='%' desc +local expl disp jobs job jids pfx='%' desc how _tags jobs || return 1 -zstyle -t ":completion${curcontext}:jobs" prefix-needed && - [[ "$PREFIX" != %* ]] && return 1 +if [[ "$1" = -t ]]; then + zstyle -t ":completion${curcontext}:jobs" prefix-needed && + [[ "$PREFIX" != %* || compstate[nmatches] -eq 0 ]] && return 1 + shift +fi zstyle -t ":completion${curcontext}:jobs" prefix-hidden && pfx='' zstyle -t ":completion${curcontext}:jobs" verbose && desc=yes @@ -31,8 +34,12 @@ if [[ -n "$desc" ]]; then done fi -if zstyle -t ":completion${curcontext}:jobs" strings; then - local texts i text str tmp +zstyle -s ":completion${curcontext}:jobs" numbers how + +if [[ "$how" = (yes|true|on|1) ]]; then + jobs=( "$jids[@]" ) +else + local texts i text str tmp num max=0 # Find shortest unambiguous strings. @@ -47,6 +54,7 @@ if zstyle -t ":completion${curcontext}:jobs" strings; then text="" fi tmp=( "${(@M)texts:#${str}*}" ) + num=1 while [[ -n "$text" && $#tmp -ge 2 ]]; do str="${str} ${text%% *}" if [[ "$text" = *\ * ]]; then @@ -55,14 +63,19 @@ if zstyle -t ":completion${curcontext}:jobs" strings; then text="" fi tmp=( "${(@M)texts:#${str}*}" ) + (( num++ )) done + [[ num -gt max ]] && max="$num" + jobs=( "$jobs[@]" "$str" ) done - [[ -n "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" ) -else - jobs=( "$jids[@]" ) + if [[ "$how" = [0-9]## && max -gt how ]]; then + jobs=( "$jids[@]" ) + else + [[ -z "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" ) + fi fi if [[ -n "$desc" ]]; then diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde index bba928f50..128fd7ffa 100644 --- a/Completion/Base/_tilde +++ b/Completion/Base/_tilde @@ -4,7 +4,7 @@ # for you or if there are too many of them, you may want to use # `compadd -qS/ - "$friends[@]"' or something like that. -local expl suf dirs list lines revlines i ret disp +local expl suf dirs list lines revlines i ret disp nm="$compstate[nmatches]" if [[ "$SUFFIX" = */* ]]; then ISUFFIX="/${SUFFIX#*/}$ISUFFIX" @@ -23,7 +23,7 @@ while _tags; do if _requested -V directory-stack expl 'directory stack' && { ! zstyle -t ":completion${curcontext}:directory-stack" prefix-needed || - [[ "$PREFIX" = [-+]* ]] }; then + [[ "$PREFIX" = [-+]* || nm -eq compstate[nmatches] ]] }; then if zstyle -t ":completion${curcontext}:directory-stack" verbose; then integer i |