summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/Utility/_arguments152
1 files changed, 78 insertions, 74 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 7087dc6bb..006e80374 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -186,6 +186,8 @@ while [[ "$1" = -(O*|[CRWsw]) ]]; do
   esac
 done
 
+[[ "$PREFIX" = [-+] ]] && alwopt=arg
+
 zstyle -s ":completion:${curcontext}:options" auto-description autod
 
 if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
@@ -227,106 +229,108 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
   while true; do
     while _tags; do
       anum=1
-      while [[ anum -le  $#descrs ]]; do
-
-	action="$actions[anum]"
-	descr="$descrs[anum]"
-	subc="$subcs[anum++]"
+      if [[ -z "$tried" ]]; then
+        while [[ anum -le  $#descrs ]]; do
 
-        if [[ -z "$tried" ]] && { [[ -n "$matched" ]] || _requested "$subc" }; then
+	  action="$actions[anum]"
+	  descr="$descrs[anum]"
+	  subc="$subcs[anum++]"
 
-          curcontext="${oldcontext%:*}:$subc"
+          if [[ -n "$matched" ]] || _requested "$subc"; then
 
-          _description "$subc" expl "$descr"
+            curcontext="${oldcontext%:*}:$subc"
 
-          if [[ "$action" = \=\ * ]]; then
-            action="$action[3,-1]"
-            words=( "$subc" "$words[@]" )
-	    (( CURRENT++ ))
-          fi
+            _description "$subc" expl "$descr"
 
-          if [[ "$action" = -\>* ]]; then
-	    action="${${action[3,-1]##[ 	]#}%%[ 	]#}"
-	    if (( ! $state[(I)$action] )); then
-              comparguments -W line opt_args
-              state=( "$state[@]" "$action" )
-	      if [[ -n "$usecc" ]]; then
-	        curcontext="${oldcontext%:*}:$subc"
-	      else
-	        context=( "$context[@]" "$subc" )
-	      fi
-              compstate[restore]=''
-              aret=yes
-            fi
-          else
-            if [[ -z "$local" ]]; then
-              local line
-              typeset -A opt_args
-              local=yes
+            if [[ "$action" = \=\ * ]]; then
+              action="$action[3,-1]"
+              words=( "$subc" "$words[@]" )
+	      (( CURRENT++ ))
             fi
 
-            comparguments -W line opt_args
+            if [[ "$action" = -\>* ]]; then
+	      action="${${action[3,-1]##[ 	]#}%%[ 	]#}"
+	      if (( ! $state[(I)$action] )); then
+                comparguments -W line opt_args
+                state=( "$state[@]" "$action" )
+	        if [[ -n "$usecc" ]]; then
+	          curcontext="${oldcontext%:*}:$subc"
+	        else
+	          context=( "$context[@]" "$subc" )
+	        fi
+                compstate[restore]=''
+                aret=yes
+              fi
+            else
+              if [[ -z "$local" ]]; then
+                local line
+                typeset -A opt_args
+                local=yes
+              fi
 
-            if [[ "$action" = \ # ]]; then
+              comparguments -W line opt_args
 
-              # An empty action means that we should just display a message.
+              if [[ "$action" = \ # ]]; then
 
-	      _message "$descr"
-	      mesg=yes
-	      tried=yes
+                # An empty action means that we should just display a message.
 
-            elif [[ "$action" = \(\(*\)\) ]]; then
+	        _message "$descr"
+	        mesg=yes
+	        tried=yes
+                alwopt=${alwopt:-yes}
+              elif [[ "$action" = \(\(*\)\) ]]; then
 
-              # ((...)) contains literal strings with descriptions.
+                # ((...)) contains literal strings with descriptions.
 
-              eval ws\=\( "${action[3,-3]}" \)
+                eval ws\=\( "${action[3,-3]}" \)
 
-              _describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]" ||
-                  alwopt=${alwopt:-yes}
-	      tried=yes
+                _describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]" ||
+                    alwopt=${alwopt:-yes}
+	        tried=yes
 
-            elif [[ "$action" = \(*\) ]]; then
+              elif [[ "$action" = \(*\) ]]; then
 
-              # Anything inside `(...)' is added directly.
+                # Anything inside `(...)' is added directly.
 
-              eval ws\=\( "${action[2,-2]}" \)
+                eval ws\=\( "${action[2,-2]}" \)
 
-              _all_labels "$subc" expl "$descr" compadd "$subopts[@]" -a - ws ||
-                  alwopt=${alwopt:-yes}
-	      tried=yes
-            elif [[ "$action" = \{*\} ]]; then
+                _all_labels "$subc" expl "$descr" compadd "$subopts[@]" -a - ws ||
+                    alwopt=${alwopt:-yes}
+	        tried=yes
+              elif [[ "$action" = \{*\} ]]; then
 
-              # A string in braces is evaluated.
+                # A string in braces is evaluated.
 
-              while _next_label "$subc" expl "$descr"; do
-                eval "$action[2,-2]" && ret=0
-              done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
-            elif [[ "$action" = \ * ]]; then
+                while _next_label "$subc" expl "$descr"; do
+                  eval "$action[2,-2]" && ret=0
+                done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              elif [[ "$action" = \ * ]]; then
 
-              # If the action starts with a space, we just call it.
+                # If the action starts with a space, we just call it.
 
-	      eval "action=( $action )"
-              while _next_label "$subc" expl "$descr"; do
-                "$action[@]" && ret=0
-              done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
-            else
+	        eval "action=( $action )"
+                while _next_label "$subc" expl "$descr"; do
+                  "$action[@]" && ret=0
+                done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              else
 
-              # Otherwise we call it with the description-arguments.
+                # Otherwise we call it with the description-arguments.
 
-	      eval "action=( $action )"
-              while _next_label "$subc" expl "$descr"; do
-                "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}" && ret=0
-	      done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
+	        eval "action=( $action )"
+                while _next_label "$subc" expl "$descr"; do
+                  "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}" && ret=0
+	        done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              fi
             fi
           fi
-        fi
-      done
+        done
+      fi
       if [[ -z "$hasopts" &&
             -z "$matched" &&
             ( -z "$tried" || -n "$alwopt" ) &&