Subject: Re: bug#43519: 28.0.50; Overlay at end of minibuf hides minibuf's real content

From: Eli Zaretskii <[email-masked]>
Date: Mon, 21 Sep 2020 17:45:08 +0300

> Date: Mon, 21 Sep 2020 14:18:07 +0000
> From: Gregory Heytings <[email-masked]>
> cc: [email-masked], [email-masked]
> 
> > I believe using window-text-pixel-size (which I already mentioned 
> > several times) will avoid any such difficulties, since that function 
> > takes all of those complications into account.  Therefore, I still don't 
> > understand why this approach is not being explored more actively.
> 
> This I don't know or understand either.  My guess is that creating a 
> candidate list by adding one candidate at a time and checking with 
> window-text-pixel-size if the result is too large would be inefficient. 

Even if the implementation indeed passes candidates through
window-text-pixel-size one by one, it is not clear to me that the
result will be slow enough to annoy.  We are talking about user
interaction, where speed is not that important.

In any case, I'd want to see numbers before deciding that this is
unacceptable.

> >> it is true that in all of these situations starting the mini-window 
> >> display at BOB would do the right thing.
> >
> > Are you sure?  What if the prompt is longer than a screen line (i.e., 
> > the prompt itself is continued on the 2nd and subsequent screen lines)? 
> > If the prompt is long, but the list of candidates is short, starting the 
> > mini-window display at BOB might fail to show some or all of the 
> > candidates, because the long prompt uses up most or all of the 
> > mini-window screen estate.
> 
> Yes I'm sure.  In the case you mention indeed some candidates will not be 
> displayed, but that's not a problem because most of the time all 
> candidates are not displayed anyway.

But with long enough prompt, you can have _none_ of the candidates
displayed.

> Of course there is the case when the prompt is, say, two characters
> less than the mini-window width, in which case no candidates will be
> displayed (if the user has (setq max-mini-window-width 1)), but this
> is unlikely to happen

"Unlikely to happen" is not a good guideline for making changes in the
display code, IME.  Guess what? most of the things I considered
"unlikely" did happen eventually.

So I prefer a more generally correct solution, especially when it's
not hard to implement.
> > Showing the last part is in general a better strategy in the use cases 
> > relevant to the mini-window, which are about user interaction.
> 
> In general yes, but not when displaying completion candidates with an 
> overlay at EOB, with the point before the overlay text.

I'm not sure the use case with overlays is indeed the indicator that a
different strategy is needed.  but even if it is, the changes you
proposed don't test for the existence of such an overlay, they test
something else, and thus can affect unrelated use cases.

> In that case you start with a blinking cursor at the top left of the
> minibuffer, without any indication of what you are doing or should
> do.

Are you talking about what we see today?  I'm not arguing to leave it
unchanged, I'm talking about what would be the better solution, and
starting always at BOB sounds sub-optimal to me.

> > I believe you assume that starting at BOB still shows enough of the text 
> > to allow the user to interact intelligently, but those are not the only 
> > cases we should keep in mind, since the prompt doesn't have to be short 
> > enough for that assumption to be true.
> 
> I tested this, and it works, even with overlong prompts.  In that case 
> (for example with (setq max-mini-window-width 1) and a prompt wider than 
> the mini-window width) the prompt disappears, but this is expected, and 
> it's a corner case that almost never happens.

The solution I proposed in my other message (assuming that it is
accepted) is more general, I think.  It also covers "corner cases"
which you are willing to disregard.