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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 Sep 2018 10:53:52 +0300

> From: Carlos Pita <[email-masked]>
> Date: Sat, 1 Sep 2018 15:50:27 +0100
> Cc: [email-masked], [email-masked]
> 
>  Would you like me to send you a patch, and run with it for a couple of
>  weeks, in case there are some unintended consequences?
> 
> Sure, it would be great, thanks!

Sorry for the delay, the patch, relative to the emacs-26 branch, is
below.  Please come back with your observations in a couple of weeks
(or earlier, if you discover some unexpected issues), and we will see
how to proceed with this.

One of the side effects of keeping the line-number face beyond EOB is
that the cursor on the EOB line will be smaller/larger than usual when
the line-number face has a non-default size.  Please tell whether you
see this is as a problem worth trying to fix (it isn't trivial).  Note
that similar effects happen in Emacs elsewhere, so this is not the
only situation where the cursor height is different from the default.

Thanks.

diff --git a/src/xdisp.c b/src/xdisp.c
index eccefa4..16b9261 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21175,14 +21175,11 @@ maybe_produce_line_number (struct it *it)
   for (const char *p = lnum_buf; *p; p++)
     {
       /* For continuation lines and lines after ZV, instead of a line
-	 number, produce a blank prefix of the same width.  Use the
-	 default face for the blank field beyond ZV.  */
-      if (beyond_zv)
-	tem_it.face_id = it->base_face_id;
-      else if (lnum_face_id != current_lnum_face_id
-	       && (EQ (Vdisplay_line_numbers, Qvisual)
-		   ? this_line == 0
-		   : this_line == it->pt_lnum))
+	 number, produce a blank prefix of the same width.  */
+      if (lnum_face_id != current_lnum_face_id
+	  && (EQ (Vdisplay_line_numbers, Qvisual)
+	      ? this_line == 0
+	      : this_line == it->pt_lnum))
 	tem_it.face_id = current_lnum_face_id;
       else
 	tem_it.face_id = lnum_face_id;