From e10df382f814955a9fbfc9bad6dd8e9017382d6f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 17 Nov 2024 13:53:54 +0530 Subject: [PATCH] Tests for erasing characters --- kitty/screen.c | 4 ++-- kitty_tests/multicell.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index 45e52393b..2b42c5015 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2438,11 +2438,11 @@ screen_delete_characters(Screen *self, unsigned int count) { void screen_erase_characters(Screen *self, unsigned int count) { - // Delete characters replacing them by spaces + // Delete characters clearing the cells if (count == 0) count = 1; unsigned int x = self->cursor->x; unsigned int num = MIN(self->columns - x, count); - nuke_multicell_char_intersecting_with(self, x, x + num, self->cursor->y, self->cursor->y + 1, true); + nuke_multicell_char_intersecting_with(self, x, x + num, self->cursor->y, self->cursor->y + 1, false); linebuf_init_line(self->linebuf, self->cursor->y); line_apply_cursor(self->linebuf->line, self->cursor, x, num, true); linebuf_mark_line_dirty(self->linebuf, self->cursor->y); diff --git a/kitty_tests/multicell.py b/kitty_tests/multicell.py index 77f5c8551..f17843af9 100644 --- a/kitty_tests/multicell.py +++ b/kitty_tests/multicell.py @@ -224,7 +224,6 @@ def test_multicell(self: TestMulticell) -> None: s.cursor.x = 2 s.delete_characters(1) assert_line('a\0c\0\0\0') - # multiline s.reset() s.draw('a'), multicell(s, 'b', scale=2), s.draw('c') @@ -241,3 +240,16 @@ def test_multicell(self: TestMulticell) -> None: assert_line('a_\0\0\0\0') assert_line('__\0\0\0\0', 1) + # Erase characters (aka replace with null) + s.reset() + s.cursor.x = 1 + s.draw('a'), multicell(s, 'b', scale=2), s.draw('c') + s.cursor.x = 0 + s.erase_characters(1) + assert_line('\0ab_c\0') + s.erase_characters(2) + assert_line('\0\0b_c\0') + assert_line('\0\0__\0\0', 1) + s.erase_characters(3) + assert_line('\0\0\0\0c\0') + assert_line('\0\0\0\0\0\0', 1)