about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_zstyle1
-rw-r--r--Completion/Core/_main_complete15
-rw-r--r--Completion/Core/_setup2
3 files changed, 13 insertions, 5 deletions
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 10f624ed3..9d77612fc 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -50,6 +50,7 @@ styles=(
   packageset		 c:packageset
   path			 'c:_path_files -/'
   ports			 c:_ports
+  prefer-ignored         c:bool
   prefix-hidden		 c:bool
   prefix-needed		 c:bool
   prompt		 c:
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 739ce2898..a5acb36f7 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -19,7 +19,7 @@
 setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
-local comp post ret=1 tmp _compskip format _comp_ignore \
+local ctxt post ret=1 tmp _compskip format _comp_ignore \
       _completers _completer _completer_num \
       _matchers _matcher _matcher_num \
       context state line opt_args val_args curcontext="$curcontext" \
@@ -66,7 +66,14 @@ _completers=( "$@" )
 _completer_num=1
 
 for _completer; do
-  zstyle -a ":completion:${curcontext/::/:${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}:}:" matcher-list _matchers ||
+  ctxt=":completion:${curcontext/::/:${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}:}:"
+
+  if zstyle -t "$ctxt" prefer-ignored && (( $compstate[alternate_nmatches] )); then
+    ret=0
+    break;
+  fi
+
+  zstyle -a "$ctxt" matcher-list _matchers ||
       _matchers=( '' )
 
   _matcher_num=1
@@ -82,7 +89,6 @@ done
 
 if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
    [[ $compstate[old_list] != shown &&
-      $compstate[nmatches] = 0 &&
       $compstate[alternate_nmatches] = 1 ]]; then
   case "$tmp" in
   show) compstate[insert]='' compstate[list]='list force' tmp='' ;;
@@ -99,7 +105,8 @@ fi
 
 if [[ -n "$tmp" || $compstate[old_list] = keep ||
       $compstate[nmatches]+$compstate[alternate_nmatches] -gt 1 ]]; then
-  [[ _last_nmatches -ge 0 && _last_nmatches -ne compstate[nmatches] ]] &&
+  [[ _last_nmatches -ge 0 &&
+     _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches ]] &&
       _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
   if [[ "$compstate[insert]" = "$_saved_insert" ]]; then
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index 408b5abfe..5d63b97ce 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -62,7 +62,7 @@ fi
     _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
 if zstyle -a ":completion:${curcontext}:$1" menu val; then
-  _last_nmatches="$nm"
+  _last_nmatches=$(( $nm + $compstate[alternate_nmatches] ))
   _last_menu_style=( "$val[@]" )
 else
   _last_nmatches=-1