diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 5cce3f0db..1c7e89917 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -6595,6 +6595,7 @@ test "Screen: resize (no reflow) less cols with scrollback scrolled up" { try testing.expectEqual(@as(usize, 2), s.cursor.y); } +// X test "Screen: resize more cols no reflow preserves semantic prompt" { const testing = std.testing; const alloc = testing.allocator; diff --git a/src/terminal/new/PageList.zig b/src/terminal/new/PageList.zig index acef3957a..288558c0c 100644 --- a/src/terminal/new/PageList.zig +++ b/src/terminal/new/PageList.zig @@ -3122,6 +3122,32 @@ test "PageList resize reflow more cols cursor in wrapped row that isn't unwrappe try testing.expectEqual(@as(size.CellCountInt, 1), cursor.y); } +test "PageList resize reflow more cols no reflow preserves semantic prompt" { + const testing = std.testing; + const alloc = testing.allocator; + + var s = try init(alloc, 2, 4, 0); + defer s.deinit(); + { + try testing.expect(s.pages.first == s.pages.last); + const page = &s.pages.first.?.data; + const rac = page.getRowAndCell(0, 1); + rac.row.semantic_prompt = .prompt; + } + + // Resize + try s.resize(.{ .cols = 4, .reflow = true }); + try testing.expectEqual(@as(usize, 4), s.cols); + try testing.expectEqual(@as(usize, 4), s.totalRows()); + + { + try testing.expect(s.pages.first == s.pages.last); + const page = &s.pages.first.?.data; + const rac = page.getRowAndCell(0, 1); + try testing.expect(rac.row.semantic_prompt == .prompt); + } +} + test "PageList resize reflow less cols no wrapped rows" { const testing = std.testing; const alloc = testing.allocator; diff --git a/src/terminal/new/Screen.zig b/src/terminal/new/Screen.zig index af6ed0e27..09992dba1 100644 --- a/src/terminal/new/Screen.zig +++ b/src/terminal/new/Screen.zig @@ -2303,6 +2303,49 @@ test "Screen: resize (no reflow) less cols with scrollback scrolled up" { // } } +test "Screen: resize more cols no reflow preserves semantic prompt" { + const testing = std.testing; + const alloc = testing.allocator; + + var s = try init(alloc, 5, 3, 0); + defer s.deinit(); + const str = "1ABCD\n2EFGH\n3IJKL"; + try s.testWriteString(str); + + // Set one of the rows to be a prompt + { + s.cursorAbsolute(0, 1); + s.cursor.page_row.semantic_prompt = .prompt; + } + + try s.resize(10, 3); + + { + const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} }); + defer alloc.free(contents); + try testing.expectEqualStrings(str, contents); + } + { + const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} }); + defer alloc.free(contents); + try testing.expectEqualStrings(str, contents); + } + + // Our one row should still be a semantic prompt, the others should not. + { + const list_cell = s.pages.getCell(.{ .active = .{ .x = 0, .y = 0 } }).?; + try testing.expect(list_cell.row.semantic_prompt == .unknown); + } + { + const list_cell = s.pages.getCell(.{ .active = .{ .x = 0, .y = 1 } }).?; + try testing.expect(list_cell.row.semantic_prompt == .prompt); + } + { + const list_cell = s.pages.getCell(.{ .active = .{ .x = 0, .y = 2 } }).?; + try testing.expect(list_cell.row.semantic_prompt == .unknown); + } +} + test "Screen: resize more cols with reflow that fits full width" { const testing = std.testing; const alloc = testing.allocator;