summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/builtins.zig12
-rw-r--r--src/file_watch.zig9
2 files changed, 16 insertions, 5 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);
}
};
diff --git a/src/file_watch.zig b/src/file_watch.zig
index 81f4ba87..148bc836 100644
--- a/src/file_watch.zig
+++ b/src/file_watch.zig
@@ -576,12 +576,19 @@ pub fn applyThemeEffect(
watchPath(fd, watches, theme_slot, null, 0, .{ .text = 0 });
if (!on) return false;
const request = colors.themeFileRequest(core, generation) orelse return false;
+ // What fails here is the ThemeFile write's failure too, which waits on
+ // this (the one-failure rule): late, as a Save's.
+ const pane = request.pane;
const bytes = filesystem.readFile(gpa, request.path) catch |err| {
colors.failThemeFile(core, generation, err);
+ core.noteLateFailure(pane);
return false;
};
defer gpa.free(bytes);
- if (!colors.loadThemeFile(core, generation, bytes, animate)) return false;
+ if (!colors.loadThemeFile(core, generation, bytes, animate)) {
+ core.noteLateFailure(pane);
+ return false;
+ }
const hash = std.hash.Wyhash.hash(0, bytes);
watchPath(fd, watches, theme_slot, request.path, generation, .{ .text = hash });
if (watches[theme_slot] == null) return false;