]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix display of wide characters in display margins on TTY frames
authorEli Zaretskii <eliz@gnu.org>
Wed, 2 Apr 2025 17:25:09 +0000 (20:25 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Apr 2025 16:51:14 +0000 (18:51 +0200)
* src/xdisp.c (display_line): Remove incomplete glyph sequence of
the last multi-column character, if not all of its glyphs fit in
the marginal area.  (Bug#77452)

(cherry picked from commit df82855aeb0038c810a451272eb34ae88984e8f6)

src/xdisp.c

index 9f6754a98ca2e2f25b4f0a7a43cc9f1587e030fb..f30e78a0d329e22e3bda47a9c6303f1cdf0b0d5c 100644 (file)
@@ -25685,7 +25685,7 @@ display_line (struct it *it, int cursor_vpos)
 
       /* Now, get the metrics of what we want to display.  This also
         generates glyphs in `row' (which is IT->glyph_row).  */
-      n_glyphs_before = row->used[TEXT_AREA];
+      n_glyphs_before = row->used[it->area];
       x = it->current_x;
 
       /* Remember the line height so far in case the next element doesn't
@@ -25732,6 +25732,7 @@ display_line (struct it *it, int cursor_vpos)
         the next one.  */
       if (it->area != TEXT_AREA)
        {
+         enum glyph_row_area area = it->area;
          row->ascent = max (row->ascent, it->max_ascent);
          row->height = max (row->height, it->max_ascent + it->max_descent);
          row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
@@ -25740,6 +25741,17 @@ display_line (struct it *it, int cursor_vpos)
          row->extra_line_spacing = max (row->extra_line_spacing,
                                         it->max_extra_line_spacing);
          set_iterator_to_next (it, true);
+         /* TTY frames cannot clip character glyphs that extend past the
+            end of the marginal areas, so we must do that here "by hand".  */
+         if (!FRAME_WINDOW_P (it->f)
+             /* If we exhausted the glyphs of the marginal area...      */
+             && it->area != area
+             /* ...and the last character was multi-column...  */
+             && it->nglyphs > 1
+             /* ...and not all of its glyphs fit in the marginal area... */
+             && row->used[area] < n_glyphs_before + it->nglyphs)
+             /* ...then reset back to the previous character.  */
+           row->used[area] = n_glyphs_before;
          /* If we didn't handle the line/wrap prefix above, and the
             call to set_iterator_to_next just switched to TEXT_AREA,
             process the prefix now.  */