From: Gerd Möllmann Date: Thu, 27 Mar 2025 05:10:46 +0000 (+0100) Subject: Don't write to bottom-right cell on ttys with AutoWrap (bug#77233) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b5a9f0712e431e679022b3f5ce41fd079b904a49;p=emacs.git 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) --- 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);