Subject: Re: bug#32337: 26.1; display-line-numbers-mode makes cursor ill-aligned when number face is changed

From: Eli Zaretskii <[email-masked]>
Date: Wed, 26 Sep 2018 18:39:42 +0300

> Date: Tue, 25 Sep 2018 22:46:49 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> > some feedback: one problem I find with this approach is that, when
> > leaving the buffer, the filled up square cursor turns into an empty
> > box and then, since the face is smaller, it becomes apparent that it's
> > being cropped at the top and at the bottom (it looks like two vertical
> > lines, not one box). Isn't it possible to use the smaller font just
> > for the beginning of the line, as it is for the lines above EOB?
> 
> Not easily, because Emacs generally uses the face of the last
> character drawn for the cursor.

I may have found a solution.  Would you please apply the following
additional patch on top of the previous one, and see if it solves the
problem with the hollow cursor at EOB, and doesn't introduce any new
problems?  Please run with it for a couple of weeks before you
conclude whether any problems are left.

TIA

diff --git a/src/xdisp.c b/src/xdisp.c
index eccefa4..06a15e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2304,7 +2304,7 @@ get_phys_cursor_geometry (struct window *w, struct glyph_row *row,
      ascent value, lest the hollow cursor looks funny.  */
   y = w->phys_cursor.y;
   ascent = row->ascent;
-  if (row->ascent < glyph->ascent)
+  if (!row->ends_at_zv_p && row->ascent < glyph->ascent)
     {
       y -= glyph->ascent - row->ascent;
       ascent = glyph->ascent;
@@ -2314,6 +2314,7 @@ get_phys_cursor_geometry (struct window *w, struct glyph_row *row,
   h0 = min (FRAME_LINE_HEIGHT (f), row->visible_height);
 
   h = max (h0, ascent + glyph->descent);
+  h = min (h, row->height);
   h0 = min (h0, ascent + glyph->descent);
 
   y0 = WINDOW_HEADER_LINE_HEIGHT (w);