mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
terminal/new: semantic prompt saving tests
This commit is contained in:
@ -6595,6 +6595,7 @@ test "Screen: resize (no reflow) less cols with scrollback scrolled up" {
|
|||||||
try testing.expectEqual(@as(usize, 2), s.cursor.y);
|
try testing.expectEqual(@as(usize, 2), s.cursor.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Screen: resize more cols no reflow preserves semantic prompt" {
|
test "Screen: resize more cols no reflow preserves semantic prompt" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
@ -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);
|
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" {
|
test "PageList resize reflow less cols no wrapped rows" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
@ -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" {
|
test "Screen: resize more cols with reflow that fits full width" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user