mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 03:25:50 +00:00
Make VS15 test check that previous grapheme is not affected
This commit is contained in:
@@ -3736,19 +3736,23 @@ test "Terminal: print invalid VS15 in emoji ZWJ sequence" {
|
||||
}
|
||||
|
||||
test "Terminal: VS15 to make narrow character with pending wrap" {
|
||||
var t = try init(testing.allocator, .{ .rows = 5, .cols = 2 });
|
||||
var t = try init(testing.allocator, .{ .rows = 5, .cols = 4 });
|
||||
defer t.deinit(testing.allocator);
|
||||
|
||||
// Enable grapheme clustering
|
||||
t.modes.set(.grapheme_cluster, true);
|
||||
|
||||
try testing.expect(t.modes.get(.wraparound));
|
||||
|
||||
try t.print(0x1F34B); // Lemon, width=2
|
||||
try t.print(0x2614); // Umbrella with rain drops, width=2
|
||||
try testing.expect(t.isDirty(.{ .screen = .{ .x = 0, .y = 0 } }));
|
||||
t.clearDirty();
|
||||
|
||||
// We only move one because we're in a pending wrap state.
|
||||
// We only move to the end of the line because we're in a pending wrap
|
||||
// state.
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.y);
|
||||
try testing.expectEqual(@as(usize, 1), t.screens.active.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 3), t.screens.active.cursor.x);
|
||||
try testing.expect(t.screens.active.cursor.pending_wrap);
|
||||
|
||||
try t.print(0xFE0E); // VS15 to make narrow
|
||||
@@ -3757,17 +3761,17 @@ test "Terminal: VS15 to make narrow character with pending wrap" {
|
||||
|
||||
// VS15 should clear the pending wrap state
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.y);
|
||||
try testing.expectEqual(@as(usize, 1), t.screens.active.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 3), t.screens.active.cursor.x);
|
||||
try testing.expect(!t.screens.active.cursor.pending_wrap);
|
||||
|
||||
{
|
||||
const str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("☔︎", str);
|
||||
try testing.expectEqualStrings("🍋☔︎", str);
|
||||
}
|
||||
|
||||
{
|
||||
const list_cell = t.screens.active.pages.getCell(.{ .screen = .{ .x = 0, .y = 0 } }).?;
|
||||
const list_cell = t.screens.active.pages.getCell(.{ .screen = .{ .x = 2, .y = 0 } }).?;
|
||||
const cell = list_cell.cell;
|
||||
try testing.expectEqual(@as(u21, 0x2614), cell.content.codepoint);
|
||||
try testing.expect(cell.hasGrapheme());
|
||||
@@ -3775,6 +3779,16 @@ test "Terminal: VS15 to make narrow character with pending wrap" {
|
||||
const cps = list_cell.node.data.lookupGrapheme(cell).?;
|
||||
try testing.expectEqual(@as(usize, 1), cps.len);
|
||||
}
|
||||
|
||||
// VS15 should not affect the previous grapheme
|
||||
{
|
||||
const lemon_cell = t.screens.active.pages.getCell(.{ .screen = .{ .x = 0, .y = 0 } }).?.cell;
|
||||
try testing.expectEqual(@as(u21, 0x1F34B), lemon_cell.content.codepoint);
|
||||
try testing.expectEqual(Cell.Wide.wide, lemon_cell.wide);
|
||||
const spacer_cell = t.screens.active.pages.getCell(.{ .screen = .{ .x = 1, .y = 0 } }).?.cell;
|
||||
try testing.expectEqual(@as(u21, 0), spacer_cell.content.codepoint);
|
||||
try testing.expectEqual(Cell.Wide.spacer_tail, spacer_cell.wide);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: VS16 to make wide character on next line" {
|
||||
|
||||
Reference in New Issue
Block a user