From: Eli Zaretskii <eliz@gnu.org>
Date: Thu, 5 Jan 2023 20:33:51 +0000 (+0200)
Subject: Avoid assertion violation due to fill-column indicator face
X-Git-Tag: emacs-29.0.90~829
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ec172d748f31121ed3d72e53e16fef5ee5f9018d;p=emacs.git

Avoid assertion violation due to fill-column indicator face

* src/xdisp.c (extend_face_to_end_of_line): Use the original
iterator metrics for the stretch glyph, the one unaffected by the
'fill-column-indicator' face.  (Bug#60580)
---

diff --git a/src/xdisp.c b/src/xdisp.c
index 6c88846e7a8..d2c91e5847b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23322,8 +23322,9 @@ extend_face_to_end_of_line (struct it *it)
 	  it->avoid_cursor_p = true;
 	  it->object = Qnil;
 
-	  const int stretch_ascent = (((it->ascent + it->descent)
-	                               * FONT_BASE (font)) / FONT_HEIGHT (font));
+	  const int stretch_height = it->ascent + it->descent;
+	  const int stretch_ascent =
+	    (stretch_height * FONT_BASE (font)) / FONT_HEIGHT (font);
 
 	  if (indicator_column >= 0
 	      && indicator_column > it->current_x
@@ -23343,8 +23344,7 @@ extend_face_to_end_of_line (struct it *it)
 	      if (stretch_width > 0)
 		{
 		  append_stretch_glyph (it, Qnil, stretch_width,
-		                        it->ascent + it->descent,
-		                        stretch_ascent);
+		                        stretch_height, stretch_ascent);
 		}
 
 	      /* Generate the glyph indicator only if
@@ -23352,6 +23352,8 @@ extend_face_to_end_of_line (struct it *it)
 	      if (it->current_x < indicator_column)
 		{
 		  const int save_face_id = it->face_id;
+		  const int save_ascent = it->ascent;
+		  const int save_descent = it->descent;
 		  it->char_to_display
 		    = XFIXNAT (Vdisplay_fill_column_indicator_character);
 		  it->face_id
@@ -23359,6 +23361,8 @@ extend_face_to_end_of_line (struct it *it)
 		                   0, extend_face_id);
 		  PRODUCE_GLYPHS (it);
 		  it->face_id = save_face_id;
+		  it->ascent = save_ascent;
+		  it->descent = save_descent;
 		}
 	    }
 
@@ -23372,8 +23376,7 @@ extend_face_to_end_of_line (struct it *it)
 		{
 		  clear_position (it);
 		  append_stretch_glyph (it, Qnil, stretch_width,
-					it->ascent + it->descent,
-					stretch_ascent);
+					stretch_height, stretch_ascent);
 		}
 	    }