Subject: bug#38563: 27.0.50; Company popup renders with newlines (?) inheriting the bg properties of the character at next line's bol

From: Eli Zaretskii <[email-masked]>
Date: Thu, 12 Dec 2019 13:32:41 +0200

> Cc: [email-masked]
> From: Dmitry Gutov <[email-masked]>
> Date: Wed, 11 Dec 2019 23:47:30 +0200
> 
> 1. Launch 'emacs -Q -L path/to/company -l company'.
> 2. Turn on company-mode and whitespace-mode.
> 3. In the scratch:
> newline
> newline
> space space space
> previous-line
> Type 'c', then M-x company-complete-common
> 
> Then wait ~3 seconds because of that "you can run this command ..." 
> nonsense which is implemented using sit-for. The popup will appear.
> 
> Observe how the space to the right of the popup is all yellow (the color 
> whitespace-mode assigns to the spaces on the next line by default).

Thanks.

The "character at next bol" sounds strange, since the display engine
has no look-ahead -- it never examines characters on the next line
while displaying the current line.  But it all starts making sense
when you recall that Company mode puts its overlay on that next line.
So the "inherited" face is not on the next line, it is at the position
where the Company overlay is set.  IOW, it's the "underlying face" for
the overlay string.

Should be fixed now, please test.

Btw, the bug is triggered because Company mode uses a weird '(default)
face, a list, instead of just 'default.  This is valid, but it wastes
a slot in the frame's face cache, so perhaps there's a good reason to
avoid that and simplify '(default) to 'default when you propertize the
tooltip text.