about summary refs log tree commit diff
path: root/Completion/Core/_multi_parts
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core/_multi_parts')
-rw-r--r--Completion/Core/_multi_parts62
1 files changed, 42 insertions, 20 deletions
diff --git a/Completion/Core/_multi_parts b/Completion/Core/_multi_parts
index d51130391..30a68d312 100644
--- a/Completion/Core/_multi_parts
+++ b/Completion/Core/_multi_parts
@@ -7,7 +7,7 @@
 # The parts of words from the array that are separated by the
 # separator character are then completed independently.
 
-local sep matches pref npref i tmp1 group expl menu pre suf
+local sep matches pref npref i tmp1 group expl menu pre suf opre osuf cpre
 typeset -U tmp2
 
 # Get the options.
@@ -40,6 +40,8 @@ fi
 
 pre="$PREFIX"
 suf="$SUFFIX"
+opre="$PREFIX"
+osuf="$SUFFIX"
 orig="$PREFIX$SUFFIX"
 
 # Special handling for menucompletion?
@@ -100,14 +102,17 @@ while true; do
         matches=( "${(@M)matches:#${tmp1[1]}*}" )
 	tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" )
 
+	PREFIX="${cpre}${pre}"
+	SUFFIX="$suf"
+
 	if (( $#tmp2 )); then
-	  compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	          -p "$pref" -qS "$sep" - "$tmp1[1]"
+	  compadd "$group[@]" "$expl[@]" -p "$pref" -qS "$sep" \
+                  -M "r:|${sep}=* r:|=*" - "$tmp1[1]"
         else
-	  compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	          -p "$pref" - "$tmp1[1]"
+	  compadd "$group[@]" "$expl[@]" -p "$pref" \
+                  -M "r:|${sep}=* r:|=*" - "$tmp1[1]"
         fi
-	return 1
+	return 0
       fi
     elif (( $#tmp1 )); then
 
@@ -118,6 +123,14 @@ while true; do
       SUFFIX="$suf"
       compadd -O matches -M "r:|${sep}=* r:|=*" - "$matches[@]"
 
+      if [[ "$pre" = *${sep}* ]]; then
+ 	PREFIX="${cpre}${pre%%${sep}*}"
+	SUFFIX="${sep}${pre#*${sep}}${suf}"
+      else
+        PREFIX="${cpre}${pre}"
+	SUFFIX="$suf"
+      fi
+
       if [[ -n "$menu" ]]; then
         # With menucompletion we just add matches for the matching
         # components with the prefix we collected and the rest from the
@@ -125,11 +138,12 @@ while true; do
 
         tmp2="$pre$suf"
         if [[ "$tmp2" = *${sep}* ]]; then
-          compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	          -p "$pref" -s "${sep}${tmp2#*${sep}}" - "$tmp1[@]"
+          compadd "$group[@]" "$expl[@]" \
+                  -p "$pref" -s "${sep}${tmp2#*${sep}}" \
+                  -M "r:|${sep}=* r:|=*" - "$tmp1[@]"
         else
-          compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	          -p "$pref" - "$tmp1[@]"
+          compadd "$group[@]" "$expl[@]" -p "$pref"\
+                  -M "r:|${sep}=* r:|=*" - "$tmp1[@]"
         fi
       else
         # With normal completion we add all matches one-by-one with
@@ -138,11 +152,12 @@ while true; do
 
         for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do
 	  if [[ "$i" = *${sep}* ]]; then
-            compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	            -S '' -p "$pref" -s "${i#*${sep}}" - "${i%%${sep}*}${sep}"
+            compadd "$group[@]" "$expl[@]" -S '' \
+	            -p "$pref" -s "${i#*${sep}}" \
+                    -M "r:|${sep}=* r:|=*" - "${i%%${sep}*}${sep}"
           else
-            compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	            -S '' -p "$pref" - "$i"
+            compadd "$group[@]" "$expl[@]" -S '' -p "$pref" \
+                    -M "r:|${sep}=* r:|=*" - "$i"
           fi
         done
       fi
@@ -154,12 +169,15 @@ while true; do
 
       [[ "$orig" = "$pref$pre$suf" ]] && return 1
 
+      PREFIX="${cpre}${pre}"
+      SUFFIX="$suf"
+
       if [[ -n "$suf" ]]; then
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	        -s "$suf" - "$pref$pre"
+        compadd "$group[@]" "$expl[@]" -s "$suf" \
+                -M "r:|${sep}=* r:|=*" - "$pref$pre"
       else
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	        -S '' - "$pref$pre$suf"
+        compadd "$group[@]" "$expl[@]" -S '' \
+                -M "r:|${sep}=* r:|=*" - "$pref$pre"
       fi
       return 0
     fi
@@ -175,8 +193,10 @@ while true; do
   # Now we set `pre' and `suf' to their new values.
 
   if [[ "$pre" = *${sep}* ]]; then
+    cpre="${cpre}${pre%%${sep}*}${sep}"
     pre="${pre#*${sep}}"
   elif [[ "$suf" = *${sep}* ]]; then
+    cpre="${cpre}${pre}${suf%%${sep}*}${sep}"
     pre="${suf#*${sep}}"
     suf=""
   else
@@ -184,9 +204,11 @@ while true; do
     # unambiguous prefix and that differs from the original string,
     # we insert it.
 
+    PREFIX="${opre}${osuf}"
+    SUFFIX=""
+
     [[ -n "$pref" && "$orig" != "$pref" ]] &&
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	        -S '' - "$pref"
+        compadd "$group[@]" "$expl[@]" -S '' -M "r:|${sep}=* r:|=*" - "$pref"
 
     return
   fi