diff --git a/kitty/graphics.c b/kitty/graphics.c index 62c78e02f..0738b938b 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -1690,6 +1690,12 @@ grman_remove_all_cell_images(GraphicsManager *self) { static bool clear_filter_func(const ImageRef *ref, Image UNUSED *img, const void UNUSED *data, CellPixelSize cell UNUSED) { + if (ref->is_virtual_ref) return false; + return ref->start_row + (int32_t)ref->effective_num_rows > 0; +} + +static bool +clear_filter_func_noncell(const ImageRef *ref, Image UNUSED *img, const void UNUSED *data, CellPixelSize cell UNUSED) { if (ref->is_virtual_ref || ref->is_cell_image) return false; return ref->start_row + (int32_t)ref->effective_num_rows > 0; } @@ -1764,7 +1770,7 @@ handle_delete_command(GraphicsManager *self, const GraphicsCommand *g, Cursor *c #define D(l, u, data, func) case l: case u: I(u, data, func) #define G(l, u, func) D(l, u, g, func) case 0: - D('a', 'A', NULL, clear_filter_func); + D('a', 'A', NULL, clear_filter_func_noncell); G('i', 'I', id_filter_func); G('p', 'P', point_filter_func); G('q', 'Q', point3d_filter_func); diff --git a/kitty_tests/graphics.py b/kitty_tests/graphics.py index 730929913..e0d05f5a0 100644 --- a/kitty_tests/graphics.py +++ b/kitty_tests/graphics.py @@ -607,6 +607,10 @@ class TestGraphics(BaseTest): self.ae(len(refs), 2) self.ae(refs[0]['src_rect'], {'left': 0.0, 'top': 0.0, 'right': 1.0, 'bottom': 0.5}) self.ae(refs[1]['src_rect'], {'left': 0.0, 'top': 0.5, 'right': 1.0, 'bottom': 1.0}) + # Now reset the screen, the images should be erased. + s.reset() + refs = layers(s) + self.ae(len(refs), 0) def test_unicode_placeholders_3rd_combining_char(self): # This test tests that we can use the 3rd diacritic for the most