about summary refs log tree commit diff
path: root/Completion/Core/_alternative
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core/_alternative')
-rw-r--r--Completion/Core/_alternative21
1 files changed, 11 insertions, 10 deletions
diff --git a/Completion/Core/_alternative b/Completion/Core/_alternative
index f13fc9e5a..76a8380bc 100644
--- a/Completion/Core/_alternative
+++ b/Completion/Core/_alternative
@@ -1,22 +1,23 @@
 #autoload
 
 local tags def expl descr action mesgs nm="$compstack[nmatches]" subopts
+local opt curcontext="$curcontext"
+
+subopts=()
+while getopts 'O:C:' opt; do
+  case "$opt" in
+  O) subopts=( "${(@P)OPTARG}" ) ;;
+  C) curcontext="${curontext}:$OPTARG" ;;
+  esac
+done
 
-if [[ "$1" = -O?* ]]; then
-  subopts=( "${(@P)1[3,-1]}" )
-  shift
-elif [[ "$1" = -O ]]; then
-  subopts=( "${(@P)2}" )
-  shift 2
-else
-  subopts=()
-fi  
+shift OPTIND-1
 
 [[ "$1" = -(|-) ]] && shift
 
 mesgs=()
 
-_tags "$1" "${(@)argv[2,-1]%%:*}"
+_tags "${(@)argv%%:*}"
 
 while _tags; do
   for def; do