mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal/new: more resize more cols tests
This commit is contained in:
@ -6513,6 +6513,12 @@ test "Screen: resize more cols perfect split" {
|
|||||||
const str = "1ABCD2EFGH3IJKL";
|
const str = "1ABCD2EFGH3IJKL";
|
||||||
try s.testWriteString(str);
|
try s.testWriteString(str);
|
||||||
try s.resize(3, 10);
|
try s.resize(3, 10);
|
||||||
|
|
||||||
|
{
|
||||||
|
const contents = try s.testString(alloc, .screen);
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings("1ABCD2EFGH\n3IJKL", contents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// X
|
// X
|
||||||
@ -6669,6 +6675,7 @@ test "Screen: resize more cols grapheme map" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
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;
|
||||||
|
@ -564,13 +564,14 @@ fn reflowPage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
src_cursor.cursorAbsolute(src_cursor.x, @intCast(src_y));
|
src_cursor.cursorAbsolute(0, @intCast(src_y));
|
||||||
|
|
||||||
for (src_cursor.x..src_cursor.page.size.cols) |src_x| {
|
for (src_cursor.x..src_cursor.page.size.cols) |src_x| {
|
||||||
assert(src_cursor.x == src_x);
|
assert(src_cursor.x == src_x);
|
||||||
|
|
||||||
if (dst_cursor.pending_wrap) {
|
if (dst_cursor.pending_wrap) {
|
||||||
@panic("TODO");
|
dst_cursor.page_row.wrap = true;
|
||||||
|
dst_cursor.cursorScroll();
|
||||||
|
dst_cursor.page_row.wrap_continuation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (src_cursor.page_cell.content_tag) {
|
switch (src_cursor.page_cell.content_tag) {
|
||||||
|
@ -2224,6 +2224,12 @@ test "Screen: resize more cols perfect split" {
|
|||||||
const str = "1ABCD2EFGH3IJKL";
|
const str = "1ABCD2EFGH3IJKL";
|
||||||
try s.testWriteString(str);
|
try s.testWriteString(str);
|
||||||
try s.resize(10, 3);
|
try s.resize(10, 3);
|
||||||
|
|
||||||
|
{
|
||||||
|
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings("1ABCD2EFGH\n3IJKL", contents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/mitchellh/ghostty/issues/1159
|
// https://github.com/mitchellh/ghostty/issues/1159
|
||||||
@ -2258,3 +2264,44 @@ test "Screen: resize (no reflow) more cols with scrollback scrolled up" {
|
|||||||
try testing.expectEqual(@as(size.CellCountInt, 1), s.cursor.x);
|
try testing.expectEqual(@as(size.CellCountInt, 1), s.cursor.x);
|
||||||
try testing.expectEqual(@as(size.CellCountInt, 2), s.cursor.y);
|
try testing.expectEqual(@as(size.CellCountInt, 2), s.cursor.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen: resize more cols with reflow that fits full width" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 5, 3, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
const str = "1ABCD2EFGH\n3IJKL";
|
||||||
|
try s.testWriteString(str);
|
||||||
|
|
||||||
|
// Verify we soft wrapped
|
||||||
|
{
|
||||||
|
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||||
|
defer alloc.free(contents);
|
||||||
|
const expected = "1ABCD\n2EFGH\n3IJKL";
|
||||||
|
try testing.expectEqualStrings(expected, contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let's put our cursor on row 2, where the soft wrap is
|
||||||
|
s.cursorAbsolute(0, 1);
|
||||||
|
{
|
||||||
|
const list_cell = s.pages.getCell(.{ .active = .{
|
||||||
|
.x = s.cursor.x,
|
||||||
|
.y = s.cursor.y,
|
||||||
|
} }).?;
|
||||||
|
try testing.expectEqual(@as(u21, '2'), list_cell.cell.content.codepoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize and verify we undid the soft wrap because we have space now
|
||||||
|
try s.resize(10, 3);
|
||||||
|
{
|
||||||
|
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings(str, contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Our cursor should've moved
|
||||||
|
// TODO
|
||||||
|
// try testing.expectEqual(@as(usize, 5), s.cursor.x);
|
||||||
|
// try testing.expectEqual(@as(usize, 0), s.cursor.y);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user