diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 11:06:47 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | f18b1adc04dad68e115bb70c42e26472733daf1d (patch) | |
| tree | 6481771f6c188f926adab201526660c90040a769 | |
| parent | 67be3b6594a60d36723000a1a33a09016b29ff97 (diff) | |
| download | pardes-f18b1adc04dad68e115bb70c42e26472733daf1d.tar.gz pardes-f18b1adc04dad68e115bb70c42e26472733daf1d.zip | |
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/<n> 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 <[email protected]>
| -rw-r--r-- | src/dump.zig | 3 | ||||
| -rw-r--r-- | src/ninep/events.zig | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/dump.zig b/src/dump.zig index 2d3c2593..1cc115be 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -852,6 +852,9 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo errdefer p.deinit(); if (previous) |old| { p.next_serial = old.next_serial; + // Columns as panes: a restored one takes a fresh serial, never one + // a column of the old session had, living or deleted. + p.next_column_serial = old.next_column_serial; p.lsp_seq = old.lsp_seq; p.pipe.seq = old.pipe.seq; p.cell_pixels = old.cell_pixels; 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"); |
