From f18b1adc04dad68e115bb70c42e26472733daf1d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 11:06:47 -0300 Subject: Column serials go on across a Restore as pane serials do: a restored column never takes a serial the old session handed out A Restore carried next_serial over for panes but started column serials at 1 again. So a restored column could take the serial a deleted column had, and a script holding col/ from before the Restore would find a different column there. The column counter is now carried over like the pane one, and restoredcol maps each old serial to a fresh one. Co-Authored-By: Claude Opus 5.5 --- src/ninep/events.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ninep') diff --git a/src/ninep/events.zig b/src/ninep/events.zig index fe7af77e..906e7a9a 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -1176,6 +1176,20 @@ test "a Dump written and a Restore made are in the log, with their files" { try testing.expect(std.mem.endsWith(u8, log.bytes, try std.fmt.bufPrint(&want, "restoredcol {d} {d}\n", .{ pardes.layout.columnSerial(p, 0), pardes.layout.columnSerial(restored, 0) }))); } +test "a Restore gives columns fresh serials, past every serial the old session handed out" { + const p = try withFile(testing.allocator, "one\n"); + defer p.deinit(); + const first = pardes.layout.columnSerial(p, 0); + // Serials spent on columns since deleted. + p.next_column_serial += 5; + const spent = p.next_column_serial; + try dump.dumpState(p); + const restored = try dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); + defer restored.deinit(); + for (0..restored.ncol) |c| try testing.expect(pardes.layout.columnSerial(restored, c) >= spent); + try testing.expect(pardes.layout.columnSerial(restored, 0) != first); +} + test "opens of the log share the open records, and a closed one frees its record" { const gpa = testing.allocator; const p = try withFile(gpa, "x\n"); -- cgit v1.3