summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index ced4329d..fa9a0fda 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -4692,6 +4692,40 @@ test "bytes: a session's output that moves nothing the digest covers (a colour s
try sameTerminals(b.a, b.r);
}
+test "bytes: a terminal's view a rollback puts back is the session's through a reflow: a view on a wrapped line's second row, joined into the row above by the session's widening, is the same row after its narrowing on every side" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
+ const b = try BytesPair.init();
+ defer b.deinit();
+ const id = b.shell.index();
+ // Lines a row and a half long, the view on the first's second row (put
+ // there alike on both sides: no step of either moved it).
+ const cols = pardes.Term.grid(b.a.core.panes[id].?.terminal).cols;
+ var line: [512]u8 = undefined;
+ const text = line[0 .. cols + cols / 2];
+ @memset(text, 'x');
+ b.a.output(.{ .output = .{ .pane = b.shell, .bytes = "\x1bc" } });
+ for (0..40) |_| {
+ b.a.output(.{ .output = .{ .pane = b.shell, .bytes = text } });
+ b.a.output(.{ .output = .{ .pane = b.shell, .bytes = "\r\n" } });
+ }
+ b.r.confirm((try b.a.pending()).?);
+ b.r.settle();
+ for ([_]*Pardes{ b.a.core, b.r.core() }) |core| pardes.Term.viewTo(core.panes[id].?.terminal.?, 1);
+ // The session's frontend widens: the line one row, the view at row 0,
+ // its cell mid-row.
+ b.r.confirm(try b.a.own(.{ .resize = .{ .cols = 200, .rows = 24 } }));
+ b.r.settle();
+ try agrees(b.a, b.r);
+ try std.testing.expectEqual(@as(?usize, 0), pardes.Term.grid(b.a.core.panes[id].?.terminal).view);
+ // A key of the client's on top, the session's first: the copy put back.
+ try b.rollback();
+ try agrees(b.a, b.r);
+ // The session narrows again: every side's view the same row.
+ b.r.confirm(try b.a.own(.{ .resize = .{ .cols = 80, .rows = 24 } }));
+ b.r.settle();
+ try agrees(b.a, b.r);
+}
+
test "bytes: a mouse motion a speculation told a terminal's program is told again when its input is replayed: the cell last told is the pane's, put back with it" {
if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const gpa = std.testing.allocator;