This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit fb6784fc4cb691cbf06752158c97f77d6b7fccb7
Author: Boris Faure <[email protected]>
AuthorDate: Mon Nov 16 22:10:50 2026 +0000

    termptyops: do not wrap or shift the row for zero-width characters
    
    A combining mark, a zero width space or a variation selector takes no
    cell, yet when it came right after a character written in the last
    column it consumed the pending wrap and moved the cursor to the next
    row. A program redrawing a full-width line ending with such a character
    then sends its own newline, and every row below ends one line too low.
    In insert mode, the same characters pushed the rest of the row aside by
    an empty cell.
    
    Skip them before the pending wrap and the insert shift, as U+FE0F
    already is.
---
 src/bin/termptyops.c         | 42 ++++++++++++++++++++++--------------------
 tests/tests.results          |  1 +
 tests/zero-width-wrapnext.sh | 29 +++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 68513a70..a7a26d91 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -404,6 +404,23 @@ termpty_text_repeat_count(const Termpty *ty, Eina_Unicode codepoint,
    return settled + ((count - settled) % per_line);
 }
 
+/* Zero-width code points take no cell: they neither consume a pending wrap
+ * nor shift the row in insert mode. U+0336 strikes the next character. */
+static inline Eina_Bool
+_zero_width_skip(Termpty *ty, Eina_Unicode g)
+{
+   /* 0-width space, RTL/LTR marks and variation selectors (U+FE0F was
+    * already handled) */
+   if (EINA_UNLIKELY((g >= 0x200b && g <= 0x200f) ||
+                     (g >= 0xfe00 && g <= 0xfe0f)))
+     return EINA_TRUE;
+   if (EINA_LIKELY(g < 0x300 || g > 0x36f))
+     return EINA_FALSE;
+   if (EINA_UNLIKELY(g == 0x336))
+     ty->termstate.combining_strike = 1;
+   return EINA_TRUE;
+}
+
 void
 termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
 {
@@ -484,6 +501,8 @@ termpty_text_append_known_ascii(Termpty *ty, const Eina_Unicode *codepoints,
 
         if (ty->cursor_state.wrapnext)
           {
+             if (_zero_width_skip(ty, g))
+               continue;
              cells[max_right-1].att.autowrapped = 1;
              ty->cursor_state.wrapnext = 0;
              ty->cursor_state.cx = origin;
@@ -523,31 +542,14 @@ termpty_text_append_known_ascii(Termpty *ty, const Eina_Unicode *codepoints,
                }
           }
 
+        if (_zero_width_skip(ty, g))
+          continue;
+
         if (ty->termstate.insert && (ty->cursor_state.cx < max_right - 1))
           TERMPTY_CELL_MOVE(ty, &(cells[ty->cursor_state.cx]),
                             &(cells[ty->cursor_state.cx + 1]),
                             max_right - 1 - ty->cursor_state.cx);
 
-        /* Skip 0-width space or RTL/LTR marks */
-        if (EINA_UNLIKELY(g >= 0x200b && g <= 0x200f))
-          {
-             continue;
-          }
-        /* Skip variation selectors (U+FE0F was already handled above) */
-        if (EINA_UNLIKELY(g >= 0xfe00 && g <= 0xfe0f))
-          {
-             continue;
-          }
-        if (EINA_UNLIKELY(g >= 0x300 && g <=0x36f))
-          {
-             /* combining chars */
-             if (EINA_UNLIKELY(g == 0x336))
-               {
-                  ty->termstate.combining_strike = 1;
-               }
-             continue;
-          }
-
         termpty_cell_codepoint_att_fill(ty, g, ty->termstate.att,
                                         &(cells[ty->cursor_state.cx]), 1);
         if (EINA_UNLIKELY(ty->termstate.combining_strike))
diff --git a/tests/tests.results b/tests/tests.results
index 8a6ddbfa..4c229233 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -239,3 +239,4 @@ xterm-osc-9-4.sh 5e1e81fce6d8d7dbe261ea21ed2491b8
 xterm-osc-9-4-reset.sh 418469754b84535141326790ebf8e941
 sd-region-to-bottom.sh a102ef27ade17a979473302b02ae78ea
 scroll-region-counts.sh 342c990e76a9bcc7a6be7a939685d841
+zero-width-wrapnext.sh 24fc65e89f6438b48ee2882e2cf2bb21
diff --git a/tests/zero-width-wrapnext.sh b/tests/zero-width-wrapnext.sh
new file mode 100644
index 00000000..8ae917f1
--- /dev/null
+++ b/tests/zero-width-wrapnext.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# zero-width characters take no cell: one written after the last column
+# must leave the pending wrap alone, and one written in insert mode must
+# not push the row aside
+
+printf '\033[2J\033[H'
+
+# a combining grave accent after the last column, then a new line: the
+# next text lands on the row just below
+printf '\033[1;71H0123456789\314\200\r\nbelow 1'
+
+# same with a zero width space and a variation selector
+printf '\033[3;71H0123456789\342\200\213\r\nbelow 3'
+printf '\033[5;71H0123456789\357\270\200\r\nbelow 5'
+
+# a combining long stroke overlay: the pending wrap still happens on the
+# next printable character, which gets struck through
+printf '\033[7;71H0123456789\314\266X'
+
+# at a right margin
+printf '\033[?69h\033[10;40s'
+printf '\033[10;31H0123456789\314\200\r\nbelow 10'
+printf '\033[?69l'
+
+# in insert mode
+printf '\033[13;1Hcombining'
+printf '\033[4h\033[13;1H\314\200\342\200\213\357\270\200\033[4l'
+printf '\033[13;20H'

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to