Subject: Re: [PATCH] _describe and literal \n
From: Daniel Shahaf <[email-masked]>
To: [email-masked]
Date: Sat, 23 Jul 2016 21:23:45 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Bart Schaefer wrote on Sat, Jul 23, 2016 at 13:00:59 -0700:
> On Jul 23,  6:04pm, Daniel Shahaf wrote:
> }
> } Gives:
> } [[[
> } % f <TAB>
> } bar  -- lorem\nipsum
> } foo  -- hello\nworld
> } ]]]
> } 
> } Is this fix correct?
> 
> Boy, that's a tough one.  If the embedded newlines mess up something else,
> like for example menuselect keeping track of lines/columns/cursor, then
> I'd say this is the closest thing to a correct quick-fix.
> 
> On the other hand if the extra newlines are handled correctly, then I'd
> say this fix isn't warranted, and it's up to the caller to decide what
> is meant when a newline appears in the descriptions.

I haven't been able to get menu selection's highlighting to misbehave.

However, consider this:

Current master:
    % _f() { a=( $'foo:hello\nworld' $'bar:lorem\nipsum' $'baz:lorem\nipsum' ); _describe descr a }
    % f <TAB>
    baz  
    foo  -- lorem\nipsum
    bar  -- hello\nworld

With the patch:
    % f <TAB>
    baz  bar  -- lorem\nipsum
    foo       -- hello\nworld

Never mind the fact that current, unpatched, master escaped the newline
this time; the more important difference is that current master arranges
the display as though the description of foo is "lorem ipsum" and of bar
is "hello world", which is incorrect.

Cheers,

Daniel