bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37641: major/minor tick faces bleed into empty lines at the end of b


From: Juanma Barranquero
Subject: bug#37641: major/minor tick faces bleed into empty lines at the end of buffer
Date: Tue, 8 Oct 2019 04:38:18 +0200

On Mon, Oct 7, 2019 at 6:17 PM Eli Zaretskii <eliz@gnu.org> wrote:

> Looks good, but please simplify by having 2-level if, the outer one
> checking when to display a number, the inner which face to use for
> that.  There's no need to test beyond_zv more than once, and AFAIR
> beyond_zv and it->what == IT_EOB are equivalent.

beyond_zv and it->what == IT_EOB are similar, but not equivalent. I see the difference when deleting empty lines at the end of the buffer (specifically, when deleting from the last line, and not past the last line).

With the `what' check, the face still bleed info the first post-EOB line. Checking beyond_zv it works (see attached images).

As for simplifying the check, it is possible to check beyond_zv only once, with the minor downside of having two paths to set lnum_face (which works as the default face, and the face post-EOB).

if (check for current line)  // checks also it->what != IT_EOB
   set face to current_lnum_face;
else if (beyond_zv)
   set face to lnum_face;  // 1
else if (check for major tick)
   set face to major_tick;
else if (check for minor tick)
   set face to minor_tick;
else
   set face to lnum_face;  // 2

BTW, if the "it->what != IT_EOB" comparison in the current line check can indeed be changed to !beyond_zv (which seems to work, at least on my tests), then you can go to

if (beyond_zv)
   set face to lnum_face;  // 1
else if (check for current line)  // does not check it->what != IT_EOB
   set face to current_lnum_face;
else if (check for major tick)
   set face to major_tick;
else if (check for minor tick)
   set face to minor_tick;
else
   set face to lnum_face; // 2

which is equally clean and saves another comparison.

And the nicest thing is that the patch is very clean (attached also because Gmail as usual is screwing with it).

diff --git a/src/xdisp.c b/src/xdisp.c
index 29d49d57df..ad73981c1d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22662,13 +22662,14 @@ maybe_produce_line_number (struct it *it)
     {
       /* For continuation lines and lines after ZV, instead of a line
         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)
-         /* Avoid displaying the line-number-current-line face on
-            empty lines beyond EOB.  */
-         && it->what != IT_EOB)
+      if (beyond_zv)
+       /* Avoid displaying any face other than line-number on
+          empty lines beyond EOB.  */
+       tem_it.face_id = lnum_face_id;
+      else 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 if (display_line_numbers_major_tick > 0
               && (lnum_to_display % display_line_numbers_major_tick == 0))

Attachment: it_eob.png
Description: PNG image

Attachment: beyond_zv.png
Description: PNG image

Attachment: beyond.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]