From: Eli Zaretskii Date: Thu, 3 Oct 2024 10:32:10 +0000 (+0300) Subject: Avoid assertion violations due to wrong 'min-width' property X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=88a78516463ff9f2fac6f2226574b6367ddbb19b;p=emacs.git Avoid assertion violations due to wrong 'min-width' property * 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) --- diff --git a/src/xdisp.c b/src/xdisp.c index 495ec821352..30046e8caf3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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; }