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

Re: [BUG] _describe -x adds same completion group header twice



On 10 Sep, Marlon Richert wrote:
>
> The problem here looks to me that compadd -x *always* adds a header,
> even when used with -D, whereas compadd -X does *not* add a header

> Which of these two should we consider at fault: _describe or compadd?
>
> It would be trivial to fix in _describe, but I feel like it would be
> better to fix in compadd, so this problem cannot possibly occur again.
> I find it hard to believe it is ever anyone's intention to add a
> visible header when calling compadd -D (or -O or -A).

Yes, I agree. The problem is in compadd. With -D, -O or -A, it shouldn't
do anything besides setting the arrays. 

The following is a minimal change that appears to do the job. It may be
possible to skip rather more of the code within compadd when any of
those options are set but that isn't trivial.

Oliver

diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 131e86825..63136854e 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2120,7 +2120,7 @@ addmatches(Cadata dat, char **argv)
             curexpl->always = !!dat->mesg;
             curexpl->count = curexpl->fcount = 0;
             curexpl->str = dupstring(dat->mesg ? dat->mesg : dat->exp);
-            if (dat->mesg)
+            if (dat->mesg && !dat->dpar && !dat->opar && !dat->apar)
                 addexpl(1);
         } else
             curexpl = NULL;




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