Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _multi_parts and -q



On Jun 18, 10:07pm, Peter Stephenson wrote:
}
} I think the issue is that "xy/foo", "xy/bar" etc. look like a set of
} ambiguous completions with "xy/" as prefix --- and in *that* case the
} "/" isn't special, it's just part of the input string.  (Possibly you
} can see some behaviour that disagrees with this hypothesis.)

That's part of it, but by examination _multi_parts never passes -q to
compadd on its own, and it only passes *through* a -q from its options
($sopts) in three cases:

(1) The separator is not in the string from the command line AND there
is exactly one possible match; or

(2) The separator is not in the string from the command line AND *none*
of the possible matches contains the separator; or

(3) The matcher list found no matches AND there's no suffix on the
command line, i.e. we're completing at the end of a word.

In fact in the most obvious case _complete_debug shows the code passing
through the compadd on line 120 which passes -r $sep -S $sep but not -q
(this is the first clause of case 2 but not the second).  This happens
even when there is an exact match that does not contain the separator.

This change makes it take the compadd at line 123 (124 after the patch)
instead, and then Danek's example works:

Index: Completion/Base/Utility/_multi_parts
===================================================================
--- Completion/Base/Utility/_multi_parts	21 Dec 2010 16:41:14 -0000
+++ Completion/Base/Utility/_multi_parts	21 Jun 2011 05:00:16 -0000
@@ -116,7 +116,8 @@
 	  compadd "$group[@]" "$expl[@]" "$sopts[@]" \
                   -M "r:|${sep}=* r:|=* $matcher" - $pref$matches
         else
-	  if (( $matches[(I)${tmp1[1]}${sep}*] )); then
+	  if (( $matches[(I)${tmp1[1]}${sep}*] )) &&
+            ! (( $matches[(I)${tmp1[1]}] )); then
 	    compadd "$group[@]" "$expl[@]" -p "$pref" -r "$sep" -S "$sep"
"$opts[@]" \
                     -M "r:|${sep}=* r:|=* $matcher" - "$tmp1[1]"
           else

By the way, do NOT pass an empty separator to _multi_parts.  Infinite loop.



Messages sorted by: Reverse Date, Date, Thread, Author