]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid assertion violations due to wrong 'min-width' property
authorEli Zaretskii <eliz@gnu.org>
Thu, 3 Oct 2024 10:32:10 +0000 (13:32 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 4 Oct 2024 10:09:10 +0000 (12:09 +0200)
* src/xdisp.c (display_min_width): Ignore 'min-width' display
specs which produce stretch glyphs wider than the window when
lines are truncated.  (Bug#73600)

(cherry picked from commit d5b02b7ad6fc67a10176a2ce56e14592252d3ed7)

src/xdisp.c

index 495ec821352d3c5496207e8d7c591478b1780d78..30046e8caf3e78d4e7835405b2b75a2daa12bdb1 100644 (file)
@@ -5689,7 +5689,13 @@ display_min_width (struct it *it, ptrdiff_t charpos,
                                          XCAR (it->min_width_property),
                                          font, true, NULL);
              width -= it->current_x - it->min_width_start;
-             w = list1 (make_int (width));
+             /* It makes no sense to try to obey min-width which yields
+                 a stretch that ends beyond the visible portion of the
+                 window if we are truncating screen lines.  If we are
+                 requested to do that, some Lisp program went awry.  */
+             if (!(it->line_wrap == TRUNCATE
+                   && it->current_x + width > it->last_visible_x))
+               w = list1 (make_int (width));
            }
          else
 #endif
@@ -5699,19 +5705,24 @@ display_min_width (struct it *it, ptrdiff_t charpos,
                                          NULL, true, NULL);
              width -= (it->current_x - it->min_width_start) /
                FRAME_COLUMN_WIDTH (it->f);
-             w = make_int (width);
+             if (!(it->line_wrap == TRUNCATE
+                   && it->current_x + width > it->last_visible_x))
+               w = make_int (width);
            }
 
          /* Insert the stretch glyph.  */
-         it->object = list3 (Qspace, QCwidth, w);
-         produce_stretch_glyph (it);
-         if (it->area == TEXT_AREA)
+         if (!NILP (w))
            {
-             it->current_x += it->pixel_width;
+             it->object = list3 (Qspace, QCwidth, w);
+             produce_stretch_glyph (it);
+             if (it->area == TEXT_AREA)
+               {
+                 it->current_x += it->pixel_width;
 
-             if (it->continuation_lines_width
-                 && it->string_from_prefix_prop_p)
-               it->wrap_prefix_width = it->current_x;
+                 if (it->continuation_lines_width
+                     && it->string_from_prefix_prop_p)
+                   it->wrap_prefix_width = it->current_x;
+               }
            }
          it->min_width_property = Qnil;
        }