]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't write to bottom-right cell on ttys with AutoWrap (bug#77233)
authorGerd Möllmann <gerd.moellmann@gmail.com>
Thu, 27 Mar 2025 05:10:46 +0000 (06:10 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 27 Mar 2025 10:12:57 +0000 (11:12 +0100)
* 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

index 864f86aa730dbdce7c851544c208e31c60c77396..8aa47322d1982355b589b6e747533648d5852534 100644 (file)
@@ -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);