diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 95cba1bf9..8880e348c 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -1546,6 +1546,8 @@ pub fn clearCells( row: *Row, cells: []Cell, ) void { + if (cells.len == 0) return; + // This whole operation does unsafe things, so we just want to assert // the end state. page.pauseIntegrityChecks(true); @@ -4084,6 +4086,18 @@ test "Screen clearRows active styled line" { try testing.expectEqualStrings("", str); } +test "Screen clearCells empty range" { + const testing = std.testing; + + var s = try Screen.init(testing.allocator, .default); + defer s.deinit(); + + const page = s.cursor.page_pin.node.page(); + const row = s.cursor.page_row; + const cells = page.getCells(row); + s.clearCells(page, row, cells[0..0]); +} + test "Screen clearRows protected" { const testing = std.testing; const alloc = testing.allocator;