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 --- src/detached/server.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/detached/server.zig') diff --git a/src/detached/server.zig b/src/detached/server.zig index e33354cf..b75fa5ad 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -4,6 +4,7 @@ const builtin = @import("builtin"); const libc = std.c; const posix = std.posix; const pardes = @import("../pardes.zig"); +const dump = @import("../dump.zig"); const wire = @import("wire.zig"); const host_io = @import("../host_io.zig"); @@ -233,7 +234,7 @@ pub const Session = struct { } pub fn restore(s: *Session, bytes: []const u8) !void { - const replacement = try s.core.restore(bytes); + const replacement = try dump.restore(s.core, bytes); s.cancelWorkers(); for (0..s.ptys.len) |pane| s.closePty(@intCast(pane)); s.harvest(); @@ -1129,7 +1130,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void const core = if (options.load_path) |lp| blk: { const bytes = try filesystem.readFile(gpa, lp); defer gpa.free(bytes); - break :blk try pardes.Pardes.initFromDump(allocs.pardes, options, bytes); + break :blk try pardes.dump.initFromDump(allocs.pardes, options, bytes); } else try pardes.Pardes.init(allocs.pardes, options); var session: Session = .{ .gpa = gpa, @@ -1197,7 +1198,7 @@ test "detached queued results preserve current requests and are discarded before try std.testing.expectEqual(current_id, s.lsp_task.?.id); try std.testing.expectEqual(current_id, s.core.lsp_wait.?.id); - try s.core.dumpState(); + try dump.dumpState(s.core); const saved = try gpa.dupe(u8, s.core.dump_out.?); defer gpa.free(saved); while (s.core.nextEffect()) |_| {} -- cgit v1.3