diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 13:45:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | a2e466a874502b665807f620eb8edefb37be1e8c (patch) | |
| tree | 25aa244348932914e3a112c76652176da2e364a4 /src/builtins.zig | |
| parent | a945c035ce9e3d5fda81a05f95f3ea1788a19ece (diff) | |
| download | pardes-a2e466a874502b665807f620eb8edefb37be1e8c.tar.gz pardes-a2e466a874502b665807f620eb8edefb37be1e8c.zip | |
A ThemeFile that cannot be read or is no theme fails its write, and a bad path says why
The theme is read when the host performs the request, after the write had been answered, so a missing file or a bad theme only showed a message; and a path not ending .zon said only invalid theme path. Load failures are now the waiting write's (late, as a Save's), and the path refusal says a theme file is a .zon.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index ca01e0fe..ec6afeae 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -808,10 +808,14 @@ pub const ThemeFile = struct { pub const requires_arg = true; pub const enabled = pardes.hosted; pub fn run(c: Ctx) void { - if (comptime enabled) - colors.requestThemeFile(c.p, c.id, c.arg orelse return) - else - unreachable; + if (comptime !enabled) unreachable; + const arg = std.mem.trim(u8, c.arg orelse return, " \t\r\n"); + // Said with why, not "invalid theme path". + if (!std.mem.endsWith(u8, arg, ".zon")) { + var said: [320]u8 = undefined; + return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "ThemeFile: {s}: invalid theme path: a theme file is a .zon (DumpThemes writes some to start from)", .{arg[0..@min(arg.len, 200)]}) catch "ThemeFile: invalid theme path: a theme file is a .zon"); + } + colors.requestThemeFile(c.p, c.id, arg); } }; |
