From 7ac21cec8d4812757995130d25b029899502e6a5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 29 Dec 2024 17:48:10 +0530 Subject: [PATCH] More multicell wrap tests --- kitty/rewrap.c | 6 ++---- kitty_tests/multicell.py | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/kitty/rewrap.c b/kitty/rewrap.c index dc3d334a936..e442b400661 100644 --- a/kitty/rewrap.c +++ b/kitty/rewrap.c @@ -128,10 +128,8 @@ init_src_line(Rewrap *r) { bool newline_needed = !r->prev_src_line_ended_with_wrap; r->init_line(r->src_buf, r->src_y, &r->src); r->src_x_limit = r->src_xnum; - if (!r->src.cpu_cells[r->src_xnum-1].next_char_was_wrapped) { - // Trim trailing blanks since there is a hard line break at the end of this line - while(r->src_x_limit && r->src.cpu_cells[r->src_x_limit - 1].ch_and_idx == BLANK_CHAR) r->src_x_limit--; - } + // Trim trailing blanks + while(r->src_x_limit && r->src.cpu_cells[r->src_x_limit - 1].ch_and_idx == BLANK_CHAR) r->src_x_limit--; r->prev_src_line_ended_with_wrap = r->src.cpu_cells[r->src_xnum - 1].next_char_was_wrapped; r->src.cpu_cells[r->src_xnum - 1].next_char_was_wrapped = false; r->src_x = 0; diff --git a/kitty_tests/multicell.py b/kitty_tests/multicell.py index d7da303b714..0d2ee06ff47 100644 --- a/kitty_tests/multicell.py +++ b/kitty_tests/multicell.py @@ -486,10 +486,29 @@ def reset(): self.ae('\x1b[maaa\x1b[ma😛\x1b[mbb', as_ansi().rstrip()) # ]]]]]]] reset() - multicell(s, 'a', scale=3) - s.draw('b'*(s.columns-3)) + multicell(s, 'a', scale=3), s.draw('b'*(s.columns-3)) s.resize(s.lines, s.columns-1) self.ae('\x1b[m\x1b]66;w=1:s=3;a\x07bb\x1b[mb', as_ansi().rstrip()) # ]] ac(0, 0, is_multicell=True) ac(0, 1, is_multicell=True) ac(3, 1, is_multicell=False, text='b') + reset() + s.draw('X'), multicell(s, 'a', scale=3), s.draw('12345') + s.resize(s.lines, s.columns-1) + self.ae('\x1b[mX\x1b]66;w=1:s=3;a\x071\x1b[m23\x1b[m45', as_ansi().rstrip()) # ]] + for y in (0, 1): + ac(0, y, is_multicell=False), ac(1, y, is_multicell=True), ac(3, y, is_multicell=True) + ac(0, 1, is_multicell=False, text='2'), ac(4, 1, is_multicell=False, text='3') + + reset() + s.draw('a'*(s.columns - 1)), s.draw('😛'), s.draw('bcd') + s.resize(s.lines, s.columns + 1) + self.ae('\x1b[maaaaa😛\x1b[mbcd', as_ansi().rstrip()) # ]]]]]]] + + reset() + s.draw('a'*s.columns), s.draw('😛'), s.draw('bcd') + s.resize(s.lines, s.columns + 1) + self.ae('\x1b[maaaaaa\x1b[m😛bcd', as_ansi().rstrip()) # ]]]]]]] + ac(s.columns-1, 0, next_char_was_wrapped=True) + s.resize(s.lines, s.columns + 1) + self.ae('\x1b[maaaaaa😛\x1b[mbcd', as_ansi().rstrip()) # ]]]]]]]