summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_normal49
1 files changed, 28 insertions, 21 deletions
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index 52f0bb352..e0375e077 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -23,11 +23,14 @@ if [[ CURRENT -eq 1 ]]; then
 
   return ret
 else
-  if [[ "$command[1]" == '=' ]]; then
+  if (( $+builtins[$command] + $+functions[$command] )); then
+    cmd1="$command"
+    curcontext="${curcontext%:*:*}:${cmd1}:"
+  elif [[ "$command[1]" = '=' ]]; then
     eval cmd1\=$command
     cmd2="$command[2,-1]"
     curcontext="${curcontext%:*:*}:${cmd2}:"
-  elif [[ "$command" == */* ]]; then
+  elif [[ "$command" = */* ]]; then
     cmd1="$command"
     cmd2="${command:t}"
     curcontext="${curcontext%:*:*}:${cmd2}:"
@@ -50,15 +53,17 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
       return ret
     fi
   done
-  for i in "${(@)_patcomps[(K)$cmd2]}"; do
-    "$i" && ret=0
-    if [[ "$_compskip" = *patterns* ]]; then
-      break
-    elif [[ "$_compskip" = all ]]; then
-      _compskip=''
-      return ret
-    fi
-  done
+  if [[ -n "$cmd2" ]]; then
+    for i in "${(@)_patcomps[(K)$cmd2]}"; do
+      "$i" && ret=0
+      if [[ "$_compskip" = *patterns* ]]; then
+        break
+      elif [[ "$_compskip" = all ]]; then
+        _compskip=''
+        return ret
+      fi
+    done
+  fi
 fi
 
 # Now look up the two names in the normal completion array.
@@ -90,16 +95,18 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
       return ret
     fi
   done
-  for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
-    _compskip=default
-    "$i" && ret=0
-    if [[ "$_compskip" = *patterns* ]]; then
-      break
-    elif [[ "$_compskip" = all ]]; then
-      _compskip=''
-      return ret
-    fi
-  done
+  if [[ -n "$cmd2" ]]; then
+    for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
+      _compskip=default
+      "$i" && ret=0
+      if [[ "$_compskip" = *patterns* ]]; then
+        break
+      elif [[ "$_compskip" = all ]]; then
+        _compskip=''
+        return ret
+      fi
+    done
+  fi
 fi
 
 [[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] &&