summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 02:40:12 -0300
committerGabriel Schneider <[email protected]>2026-10-01 02:40:12 -0300
commit3bddd662eac9a7829174f3c54b498bda84df1961 (patch)
tree4986bfc96c0582dceb928701a1b08489168b1ee9 /src/ninep/ctl.zig
parent6c0e9c5a6b6d4b0aa77f084fdac5eb4f6d1f482b (diff)
downloadpardes-3bddd662eac9a7829174f3c54b498bda84df1961.tar.gz
pardes-3bddd662eac9a7829174f3c54b498bda84df1961.zip
A Restore, or -l, of a dump naming a ThemeFile asks the host to load it again, as a /ctl write of it does
The dump's ThemeFile line went to the settings table, which has no such setting and never asks the host to read a file, so a restored session came back in the default theme. The restore now makes the request a /ctl ThemeFile makes, and the host loads the file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index e963da3f..6326b1c0 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2034,6 +2034,29 @@ test "DumpConfig's whole report writes back to the root ctl, line by line, with
}
}
+test "a Restore asks again for the ThemeFile the dump names, as a /ctl write of it does" {
+ if (comptime !pardes.hosted) return;
+ const gpa = testing.allocator;
+ const p = try withFile(gpa, "x\n");
+ defer p.deinit();
+ const good = "/tmp/pardes-restored-theme.zon";
+ _ = wr(p, @intFromEnum(tree.TopFile.ctl), "ThemeFile " ++ good ++ "\n");
+ var custom = pardes.themes[0];
+ custom.name = "restored";
+ var encoded: std.Io.Writer.Allocating = .init(gpa);
+ defer encoded.deinit();
+ try std.zon.stringify.serialize(custom, .{}, &encoded.writer);
+ try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written(), false));
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon");
+ defer restored.deinit();
+ const asked = while (restored.nextEffect()) |effect| switch (effect) {
+ .theme_file => |t| if (t.on) break t,
+ else => {},
+ } else return error.NoThemeFileAsked;
+ try testing.expectEqualStrings(good, pardes.colors.themeFileRequest(restored, asked.generation).?.path);
+}
+
test "a ThemeFile that fails to load changes nothing: the root ctl still names the one loaded, or none" {
if (comptime !pardes.hosted) return;
const gpa = testing.allocator;