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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Sep 2020 23:10:36 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 19 Sep 2020 15:42:12 -0400
> 
> > Seems like a bug in icomplete: it attempts to compute the maximum
> > length of candidates to be displayed, but seems like it fails, because
> > the single mini-window line is continued, with no ellipsis at the end
> > of the visible line?
> 
> I disagree: icomplete merely added text after point via an overlay and
> didn't do anything which explicitly justifies horizontal scrolling.

Maybe I'm missing something, but what does the code in
icomplete-completions that calls string-width and window-width try to
do, then?  I mean this part:

	     ;;"-prospects" - more than one candidate
	     (prospects-len (+ (string-width
				(or determ (concat open-bracket close-bracket)))
			       (string-width icomplete-separator)
			       (+ 2 (string-width ellipsis)) ;; take {…} into account
			       (string-width (buffer-string))))
             (prospects-max
              ;; Max total length to use, including the minibuffer content.
              (* (+ icomplete-prospects-height
                    ;; If the minibuffer content already uses up more than
                    ;; one line, increase the allowable space accordingly.
                    (/ prospects-len (window-width)))
                 (window-width)))

> I suspect the problem is that point is right on the overlay, so in
> a sense it's both before *and* after the "{...}" text.

The point is at EOB, and we have an overlay string there.  The overlay
string has a 'cursor' property on its first character, so the display
engine puts the cursor there.  Without that, we'd have the cursor at
the end of the overlay string, thus showing something even less
reasonable.

But I'm not sure how this is related to the issue at hand.

> > It should produce an overlay string that fits in the window, then the
> > prompt will be visible.
> 
> That would merely work around the underlying problem

What do you think is the underlying problem?

> (and as you know it's wickedly difficult to construct a string which
> will have "just the right size" to fit into the minibuffer window).

It doesn't have to be "just the right size", it could err on the safe
side.  It already attempts to do so, by avoiding truncation in the
middle of a candidate.  It should just do a better job, that's all.

> Maybe there's a good reason for the redisplay to behave this way

Behave in what way? what's special about what you see on display in
this case, given the contents of the mini-window's buffer?