From 7ba54de4bd498c2a56ea3d0d43c88356759f7b1f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 22:34:56 -0300 Subject: Move saving and loading a whole editor out of pardes.zig into dump.zig Pure move, no behaviour change (acme keeps dump and load in rows.c): dumpState, restore, initFromDump and initDump go verbatim to the end of dump.zig, after the dump format they read and write. Inside dump.zig the moved code's `dump.` prefix drops, so `Pane` there is the dump record; the one editor pane it names is spelled `pardes.panes.Pane`, and its other `panes.X` references become `pardes.panes.X` because dump.zig's own tests use `panes` as a local name. The methods become free functions taking `p: *Pardes`: `p.dumpState()` becomes `dump.dumpState(p)`, `core.restore(bytes)` becomes `dump.restore(core, bytes)` and `Pardes.initFromDump(..)` becomes `dump.initFromDump(..)`, in pardes.zig, the shells, layout.zig, Terminal.zig, builtins.zig and the tests (38 receiver rewrites plus the initFromDump calls). The tag-tail restore helpers stay with the tag code. Co-Authored-By: Claude Opus 5.5 --- test/panes.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/panes.zig') diff --git a/test/panes.zig b/test/panes.zig index f99f9d56..1c861070 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2039,7 +2039,7 @@ test "file history survives PDF fallback restoration and allocation failures" { var succeeded = false; for (0..256) |failure| { var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = failure }); - if (Pardes.initFromDump(failing.allocator(), .{ .tty_only = true }, saved)) |p| { + if (pardes.dump.initFromDump(failing.allocator(), .{ .tty_only = true }, saved)) |p| { defer p.deinit(); const pane = p.panes[0].?; try std.testing.expect(pane.file != null); @@ -2416,8 +2416,8 @@ const OutputTests = struct { neighbor_colored = neighbor_colored or style != 0; try std.testing.expect(neighbor_colored); - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const restored_source = restored.panes[0].?; const restored_id = pane.search_pane.?; @@ -2520,8 +2520,8 @@ const OutputTests = struct { try std.testing.expectEqual(.match, file.location_rows[next].kind); const wrapped = panes.Output.nextResult(file.content, file.location_rows, path, .{ .line = 99 }); try std.testing.expectEqual(@as(usize, 2), file.location_rows[wrapped].at.line); - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const restored_file = &restored.panes[pane.search_pane.?].?.file.?; try std.testing.expectEqualStrings(file.content, restored_file.content); -- cgit v1.3