summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 02:43:34 -0300
committerGabriel Schneider <[email protected]>2026-11-20 11:16:31 -0300
commitb58e9b3123aaa72dff67631e7f5c0b5a55b64075 (patch)
tree742e86d64590c9cc67ba9b0b5e4ebd5d30daeeb7 /core
parent4c5edb516c6c866fe6039037636804f4e868f4bb (diff)
downloadpardes-b58e9b3123aaa72dff67631e7f5c0b5a55b64075.tar.gz
pardes-b58e9b3123aaa72dff67631e7f5c0b5a55b64075.zip
term: wide characters in a pruned, reflowed scrollback snapshot and load exactly (a test, core/term/terminal.zig: the soak's wide line among 30,000 lines in a 1 MiB history, reflowed twice at odd widths: the loaded terminal's snapshot is the first's, its join hash the reload's, and both go on as one through the rest and two more reflows; it passes on the base: pardes's snapshot and ghostty's are not at fault), so the soak's `cat` gets its wide lines back (the ASCII filter deleted): the divergence seen with them (seed 0 at 80 ms, a join's reload hash) was the refused join's skipped reload of the change before; and the soak's far client never types Detach (it left once, seed 6 at 80 ms, and the run failed for a final screen it could not show; the random draw is made as before, so no other client's script moves), and a run whose far client never shows its final screen says so and why; the soak, bytes, `--clients 5 --bytes --seeds 8` at 30/80/207 ms with the `cat` whole (Debug, load 25-44): 2 of 4 whole runs clean (diverged 0, unequal 0, quiet checks agreed, unlisted 0, corpus 22 of 22, no leak); in the other two, seed 2 at 80 ms (two clients at one session unit) and seed 0 at 30 ms (one client): OPEN, not root-caused (reports/pardes-term-join.md), never under a probe; seed 0 at 30 ms, 19 of 20 clean, one run hung spinning (killed, no trace); on the base seed 0 at 30 ms diverged every time and 9 of 24 runs; tui core-test 859/1011 (152 skipped), shell-test 1047/1050
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-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 055c8981..2f9f7b33 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -1801,3 +1801,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);
+}