summaryrefslogtreecommitdiff
path: root/src/rollback.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/rollback.zig')
-rw-r--r--src/rollback.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rollback.zig b/src/rollback.zig
index bb3ac2dc..9c4f6c05 100644
--- a/src/rollback.zig
+++ b/src/rollback.zig
@@ -646,3 +646,33 @@ test "a rollback leaves the store and Recent as a speculation left them: they li
try std.testing.expectEqual(@as(usize, 0), e.live.count());
}
+test "a view drawn outside a step (a replica's own, another live) leaves the live view's slot holding nothing a rollback could put old bytes back through" {
+ var e: Epoch = .{};
+ defer e.deinit();
+ const gpa = e.allocator();
+ const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml", .image_allocator = gpa, .pdf_allocator = gpa, .tree_sitter_allocator = gpa, .frame_allocator = gpa });
+ defer p.deinit();
+ p.pump(.{}) catch {};
+ _ = p.openView() orelse return error.NoView;
+ const text = "the column tag of view 0, its own";
+ p.col_tags[0].own = try gpa.dupe(u8, text);
+ // View 1 read (as a replica client's frontend reads its own) while view
+ // 0 is live: 0 parked and put back.
+ const Read = struct {
+ fn read(_: void, _: *Pardes) anyerror!void {}
+ };
+ try pardes.views.within(p, 1, {}, Read.read);
+ const was = p.col_tags[0].own.?;
+ gpa.free(was);
+ p.col_tags[0].own = null;
+ const other = try gpa.alloc(u8, text.len);
+ defer gpa.free(other);
+ if (other.ptr != was.ptr) return error.SkipZigTest; // the heap handed out another
+ @memset(other, 'a');
+ var c: Copy = .{};
+ defer c.deinit();
+ try c.take(&e, p);
+ @memset(other, 'b');
+ c.restore();
+ try std.testing.expect(std.mem.allEqual(u8, other, 'b'));
+}