diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-11-08 09:20:42 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-11-08 09:20:42 +0000 |
commit | e0dc80e0e54df85329b1644001df80e908fd5b9c (patch) | |
tree | 2e6a623e3e31c6914f219b3dfebca4c97ad4dfdc /Completion/Core/_match | |
parent | 551fbeeab90505f0d2cafcf8c853ebc0f9e0dc0c (diff) | |
download | zsh-e0dc80e0e54df85329b1644001df80e908fd5b9c.tar.gz zsh-e0dc80e0e54df85329b1644001df80e908fd5b9c.tar.xz zsh-e0dc80e0e54df85329b1644001df80e908fd5b9c.zip |
aloow value `pattern' for insert-unambiguous style to preserve patterns in the original string; add list-suffixes style to make file completion list path suffixes if possible; slightly improved completion of pathnames with multiple pattern-components (13128)
Diffstat (limited to 'Completion/Core/_match')
-rw-r--r-- | Completion/Core/_match | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/Completion/Core/_match b/Completion/Core/_match index 3059935d8..ce2b8affe 100644 --- a/Completion/Core/_match +++ b/Completion/Core/_match @@ -11,41 +11,60 @@ ### Shouldn't be needed any more: [[ _matcher_num -gt 1 ]] && return 1 -local tmp opm="$compstate[pattern_match]" ret=0 orig ins +local tmp opm="$compstate[pattern_match]" ret=1 orig ins +local oms="$_old_match_string" +local ocsi="$compstate[insert]" ocspi="$compstate[pattern_insert]" # Do nothing if we don't have a pattern. tmp="${${:-$PREFIX$SUFFIX}#[~=]}" [[ "$tmp:q" = "$tmp" ]] && return 1 +_old_match_string="$PREFIX$SUFFIX$HISTNO" + zstyle -s ":completion:${curcontext}:" match-original orig -zstyle -b ":completion:${curcontext}:" insert-unambiguous ins +zstyle -s ":completion:${curcontext}:" insert-unambiguous ins # Try completion without inserting a `*'? if [[ -n "$orig" ]]; then compstate[pattern_match]='-' - _complete && ret=1 + _complete && ret=0 compstate[pattern_match]="$opm" - if (( ret )); then - [[ "$ins" = yes && - $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && - compstate[pattern_insert]=unambiguous - return 0 - fi + # No completion with inserting `*'? + + [[ ret -eq 1 && "$orig" = only ]] && return 1 +fi + +if (( ret )); then + compstate[pattern_match]='*' + _complete && ret=0 + compstate[pattern_match]="$opm" fi -# No completion with inserting `*'? +if (( ! ret )); then -[[ "$orig" = only ]] && return 1 + if [[ "$ins" = pattern && $compstate[nmatches] -gt 1 ]]; then -compstate[pattern_match]='*' -_complete && ret=1 -compstate[pattern_match]="$opm" + [[ "$oms" = "$PREFIX$SUFFIX$HISTNO" && + "$compstate[insert]" = automenu-unambiguous ]] && + compstate[insert]=automenu + [[ "$compstate[insert]" != *menu ]] && + compstate[pattern_insert]= compstate[insert]= -[[ ret -eq 1 && "$ins" = yes && - $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && - compstate[pattern_insert]=unambiguous +# We tried to be clever here, making completion insert unambiguous +# expansions as early as possible, but this is really hard to test +# and the code below probably does more harm than good. +# +# [[ $compstate[unambiguous_cursor] -gt $#compstate[unambiguous] ]] && +# ins=yes compstate[insert]="$ocsi" compstate[pattern_insert]="$ocspi" + fi + + [[ "$ins" = (true|yes|on|1) && + $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && + compstate[pattern_insert]=unambiguous + +fi -return 1-ret +return ret |