Subject: bug#42039: 27.0.91; (posn-x-y (posn-at-point)) inconsistent with display-line-numbers-mode

From: Dmitry Gutov <[email-masked]>
Date: Thu, 25 Jun 2020 21:35:59 +0300

On 25.06.2020 20:42, Eli Zaretskii wrote:
> The bug-report buffer doesn't use an overlay, it uses a display
> property string.  Do you have an example with an overlay where this
> problem happens, or is it limited to display strings?

Good question. It doesn't happen with just any overlay, so here's a full 
example:

1. Create an overlay, e.g.

(setq o (make-overlay (point) (1+ (point))))

The buffer contents seem unimportant. It can cover some text, or a 
newline, or multiple lines. But it should start at bol (if it doesn't 
start at bol, the result will also be unexpected, but not 0).

So the buffer text can just be a bunch of newlines, for the sake of this 
example.

2. Put a display string on it that (important!) ends with a newline:

(overlay-put o 'display "abc\ndef\n")

3. Eval

(car (posn-x-y (posn-at-point (overlay-start o))))

It will evaluate to 0 even if display-line-numbers-mode is enabled.