summaryrefslogtreecommitdiff
path: root/core/term
diff options
context:
space:
mode:
Diffstat (limited to 'core/term')
-rw-r--r--core/term/terminal.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index e57193a6..1673a3d8 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -1792,3 +1792,34 @@ test "a join at a cut: every side reloaded from its own snapshot holds the same
// another terminal once heavy colour has pruned pages cut otherwise.
try std.testing.expectEqual(2, heavy_apart);
}
+
+test "wide characters filling a scrollback past its limit, reflowed: its snapshot loads to the same snapshot and hash, and goes on as the same terminal through more bytes and reflows" {
+ // The soak's `cat` (test/replicas.zig): source lines, one in a few
+ // hundred with wide characters (CJK, box drawing, ambiguous symbols),
+ // a full scrollback pruned a page at a time, reflowed at odd widths
+ // where a wide character meets the right edge.
+ const gpa = std.testing.allocator;
+ var out: std.Io.Writer.Allocating = .init(gpa);
+ defer out.deinit();
+ const wide = " try writeText(notes, \"# Fallback faces and rules\\n\\n| name | glyphs |\\n|------|--------|\\n| cjk | \u{754C}\u{9762}\u{5B57} |\\n| sym | \u{222E} \u{2260} \u{2605} |\\n\\n\u{250C}\u{2500}\u{2500}\u{252C}\u{2500}\u{2500}\u{2510}\\n\u{2502} a\u{2502} b\u{2502}\\n\u{2514}\u{2500}\u{2500}\u{2534}\u{2500}\u{2500}\u{2518}\\n\");";
+ for (0..30000) |i| {
+ if (i % 7 == 3) try out.writer.print("{s}\r\n", .{wide}) else try out.writer.print("{s} {d}\r\n", .{ " const line = std.fmt.bufPrint(&buf, \"{d}\", .{i}) catch continue;"[0 .. 8 + i % 60], i });
+ }
+ const bytes = out.written();
+ const stops: [2]usize = .{ bytes.len / 3, 2 * bytes.len / 3 };
+ const first = try openKeeping(gpa, 121, 40, 1 << 20);
+ defer close(first);
+ feedReflowing(first, bytes, 0, bytes.len / 2, stops);
+ const snap = try snapshotOf(gpa, first);
+ defer gpa.free(snap);
+ const loaded = try load(gpa, snap, &parts(first));
+ defer close(loaded);
+ const again = try snapshotOf(gpa, loaded);
+ defer gpa.free(again);
+ try std.testing.expectEqualSlices(u8, snap, again);
+ try std.testing.expectEqual(joinHash(snap), try reload(first));
+ try expectSame(gpa, first, loaded);
+ feedReflowing(first, bytes, bytes.len / 2, bytes.len, stops);
+ feedReflowing(loaded, bytes, bytes.len / 2, bytes.len, stops);
+ try expectSame(gpa, first, loaded);
+}