From a6c4ab97de9f9624d4d4d37a4f63cae342e314fb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 23:48:17 -0300 Subject: A dump keeps the settings changed from a fresh session's, and Restore sets them A session running with Placement pardes came back from Restore as acme: a dump kept the layout and the theme but no setting. It now keeps every setting line that differs from a fresh session's, as the root ctl reads it, and a Restore applies them; the theme stays where it was kept, the font the frontend's, and REPL bindings are still dropped. The dump golden gains the three the snapshot harness sets. Co-Authored-By: Claude Opus 5.5 --- src/ninep/ctl.zig | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/ninep') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 4faa7df7..11de3c1c 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -333,13 +333,22 @@ const e_prompt = "control message needs its argument"; /// What is not a setting -- platform, themes, where the config came from -- /// is /status's or the Config window's. fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void { - const s = &p.settings; + try writeSettingsOf(p, &p.settings, w); + try w.writeAll("LocationsConfig "); + try p.locations_config.write(w); + try w.writeByte('\n'); + if (comptime builtins.Pet.enabled) try w.print("Pet {s}\n", .{@tagName(p.settings.pet)}); +} + +/// The setting words of `s`, one a line, as the root ctl reads them; a Dump +/// keeps those that differ from a fresh session's (dump.zig). +pub fn writeSettingsOf(p: *Pardes, s: *const config.Runtime, w: *std.Io.Writer) !void { inline for (config.Runtime.settings) |setting| { if (comptime !setting.enabled(builtins.capabilities)) continue; const word = setting.word; switch (setting.action) { .toggle => |field| try w.print("{s} {s}\n", .{ word, if (@field(s, @tagName(field))) "on" else "off" }), - .theme => try w.print("{s} {s}\n", .{ word, p.theme().name }), + .theme => try w.print("{s} {s}\n", .{ word, if (s == &p.settings) p.theme().name else pardes.themes[s.theme].name }), .shell => { const chosen = s.shell.requested.get(); try w.print("{s} {s}\n", .{ word, if (chosen.len > 0) chosen else config.default_shell }); @@ -360,7 +369,6 @@ fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void { inline else => |field| try w.print("{s} {s}\n", .{ word, @tagName(@field(s, @tagName(field))) }), }, .message_ms => |which| try w.print("{s} {d}\n", .{ word, @field(s, "message_" ++ @tagName(which) ++ "_ms") }), - // Bare, it names the default directory. // The directory in effect, as Config reports it; bare only when // there is none (no home to put the default in). .dump_dir => { @@ -377,10 +385,6 @@ fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void { .grip_width => try w.print("{s} {d}\n", .{ word, s.grip_width }), } } - try w.writeAll("LocationsConfig "); - try p.locations_config.write(w); - try w.writeByte('\n'); - if (comptime builtins.Pet.enabled) try w.print("Pet {s}\n", .{@tagName(s.pet)}); } pub fn rootLen(p: *Pardes) u64 { -- cgit v1.3