From b5a9f0712e431e679022b3f5ce41fd079b904a49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Thu, 27 Mar 2025 06:10:46 +0100 Subject: [PATCH] Don't write to bottom-right cell on ttys with AutoWrap (bug#77233) * src/term.c (tty_write_glyphs): Handle case of writing only one character in the last column. (cherry picked from commit 1883a5c7174eeede8fe307e73014628edca6b614) --- src/term.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/term.c b/src/term.c index 864f86aa730..8aa47322d19 100644 --- a/src/term.c +++ b/src/term.c @@ -977,10 +977,20 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) if (AutoWrap (tty) && curY (tty) + 1 == FRAME_TOTAL_LINES (f) && curX (tty) + len == FRAME_COLS (f) - && curX (tty) < FRAME_COLS (f) - 1 && len > 0) { - /* Write glyphs except the first. */ + /* If writing only one glyph in the last column, make that two so + that we can shift that one glyph into the last column. FIXME: + Assuming a display width of 1 looks questionable, but that's + done everywhere else involving auto-wrap. */ + if (len == 1) + { + cmgoto (tty, curY (tty), curX (tty) - 1); + --string; + ++len; + } + + /* Write glyphs except the first. */ int old_x = curX (tty), old_y = curY (tty); tty_write_glyphs_1 (f, string + 1, len - 1); -- 2.39.5