about summary refs log tree commit diff
path: root/Completion/Core/_complete
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core/_complete')
-rw-r--r--Completion/Core/_complete21
1 files changed, 16 insertions, 5 deletions
diff --git a/Completion/Core/_complete b/Completion/Core/_complete
index f351c7349..235265326 100644
--- a/Completion/Core/_complete
+++ b/Completion/Core/_complete
@@ -2,16 +2,21 @@
 
 # Generate all possible completions. Note that this is not intended as
 # a normal completion function, but as one possible value for the
-# compconfig[completer] parameter.
+# completer style.
 
-local comp name _tag_context="$_tag_context"
+local comp name curcontext="$curcontext" oldcontext
 
-[[ "$compstate[context]" != command || CURRENT -eq 1 ]] && 
-    _tag_context="-${compstate[context]:s/_/-/}-"
+# Probably set initial context.
+
+[[ -z "$curcontext" ]] && curcontext=':complete'
+
+oldcontext="$curcontext"
 
 # If we have a user-supplied context name, use only that.
 
 if [[ -n "$compcontext" ]]; then
+  curcontext="${curcontext}:$compcontext"
+
   comp="$_comps[$compcontext]"
   [[ -z "$comp" ]] || "$comp"
 
@@ -22,6 +27,7 @@ fi
 
 comp="$_comps[-first-]"
 if [[ ! -z "$comp" ]]; then
+  curcontext="${curcontext}:-first-"
   "$comp"
   if [[ "$_compskip" = all ]]; then
     _compskip=''
@@ -34,12 +40,17 @@ fi
 # For arguments and command names we use the `_normal' function.
 
 if [[ "$compstate[context]" = command ]]; then
+  curcontext="$oldcontext"
   _normal -s
 else
   # Let's see if we have a special completion definition for the other
   # possible contexts.
 
-  comp="$_comps[$_tag_context]"
+  local cname="-${compstate[context]:s/_/-/}-"
+
+  curcontext="${oldcontext}:$cname"
+
+  comp="$_comps[$cname]"
 
   # If not, we use default completion, if any.