Skip to content

Commit

Permalink
More multicell wrap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Dec 29, 2024
1 parent 57fd037 commit 7ac21ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 2 additions & 4 deletions kitty/rewrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 21 additions & 2 deletions kitty_tests/multicell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()) # ]]]]]]]

0 comments on commit 7ac21ce

Please sign in to comment.