From: Eli Zaretskii Date: Wed, 2 Apr 2025 17:25:09 +0000 (+0300) Subject: Fix display of wide characters in display margins on TTY frames X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=860ca6e1dc3dd7ccb1e05fe0bdd4d19a53dceab7;p=emacs.git Fix display of wide characters in display margins on TTY frames * 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) --- diff --git a/src/xdisp.c b/src/xdisp.c index 9f6754a98ca..f30e78a0d32 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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. */