diff options
Diffstat (limited to 'Completion/Base/Completer')
-rw-r--r-- | Completion/Base/Completer/_approximate | 48 | ||||
-rw-r--r-- | Completion/Base/Completer/_expand | 2 | ||||
-rw-r--r-- | Completion/Base/Completer/_prefix | 9 |
3 files changed, 25 insertions, 34 deletions
diff --git a/Completion/Base/Completer/_approximate b/Completion/Base/Completer/_approximate index dcd8b2776..96860b5a7 100644 --- a/Completion/Base/Completer/_approximate +++ b/Completion/Base/Completer/_approximate @@ -12,7 +12,6 @@ local _comp_correct _correct_expl _correct_group comax cfgacc match local oldcontext="${curcontext}" opm="$compstate[pattern_match]" -local dounfunction integer ret=1 if [[ "$1" = -a* ]]; then @@ -44,34 +43,31 @@ fi _tags corrections original -# Otherwise temporarily define a function to use instead of -# the builtin that adds matches. This is used to be able -# to stick the `(#a...)' in the right place (after an -# ignored prefix). +# Otherwise temporarily define a function to use instead of the builtin that +# adds matches. This is used to be able to stick the `(#a...)' in the right +# place (after an ignored prefix). # -# Current shell structure for use with "always", to make sure -# we unfunction the compadd. +# Current shell structure for use with "always", to make sure we unfunction our +# compadd and restore any compadd function defined previously. { -if (( ! $+functions[compadd] )); then - dounfunction=1 - compadd() { - local ppre="$argv[(I)-p]" - - [[ ${argv[(I)-[a-zA-Z]#U[a-zA-Z]#]} -eq 0 && - "${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return - - if [[ "$PREFIX" = \~* && ( ppre -eq 0 || "$argv[ppre+1]" != \~* ) ]]; then - PREFIX="~(#a${_comp_correct})${PREFIX[2,-1]}" - else - PREFIX="(#a${_comp_correct})$PREFIX" - fi +_shadow -s _approximate compadd +compadd() { + local ppre="$argv[(I)-p]" - (( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) && - _correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]} + [[ ${argv[(I)-[a-zA-Z]#U[a-zA-Z]#]} -eq 0 && + "${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return - builtin compadd "$_correct_expl[@]" "$@" - } -fi + if [[ "$PREFIX" = \~* && ( ppre -eq 0 || "$argv[ppre+1]" != \~* ) ]]; then + PREFIX="~(#a${_comp_correct})${PREFIX[2,-1]}" + else + PREFIX="(#a${_comp_correct})$PREFIX" + fi + + (( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) && + _correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]} + + compadd@_approximate "$_correct_expl[@]" "$@" +} _comp_correct=1 @@ -115,7 +111,7 @@ while [[ _comp_correct -le comax ]]; do done } always { - [[ -n $dounfunction ]] && (( $+functions[compadd] )) && unfunction compadd + _unshadow } (( ret == 0 )) && return 0 diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index 86b4ac6e4..e5e4f9b39 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -105,7 +105,7 @@ subd=("$exp[@]") # We need to come out of this with consistent quoting, by hook or by crook. integer done_quote -local orig_exp=$exp +local -a orig_exp=( $exp ) if [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob; then eval 'exp=( ${~exp//(#b)\\([ \"'"\'"' ])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && (( $#exp )) && done_quote=1 diff --git a/Completion/Base/Completer/_prefix b/Completion/Base/Completer/_prefix index 74be5f47d..aea2f7863 100644 --- a/Completion/Base/Completer/_prefix +++ b/Completion/Base/Completer/_prefix @@ -49,13 +49,8 @@ for tmp in "$comp[@]"; do fi if [[ "$tmp" != _prefix ]] && "$tmp"; then - [[ compstate[nmatches] -gt 1 ]] && return 0 - compadd -U -i "$IPREFIX" -I "$ISUFFIX" - "${compstate[unambiguous]%$suf}x" - compstate[list]= - if [[ -n $compstate[unambiguous] ]]; then - compstate[insert]=unambiguous - else - compstate[insert]=0 + if [[ -n $compstate[old_list] || ${compstate[unambiguous]%$suf} == $PREFIX ]]; then + compstate[to_end]=match fi return 0 fi |