fix: crash when switching from a customized theme

This commit is contained in:
CJ van den Berg 2025-10-21 18:14:27 +02:00
parent 84ef11a58f
commit 724543f7a1
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -763,23 +763,20 @@ fn refresh_input_mode(self: *Self) command.Result {
}
fn set_theme_by_name(self: *Self, name: []const u8, action: enum { none, store }) !void {
const old = switch (self.color_scheme) {
.dark => self.dark_parsed_theme,
.light => self.light_parsed_theme,
};
defer if (old) |p| p.deinit();
const theme_, const parsed_theme = get_theme_by_name(self.allocator, name) orelse {
self.logger.print("theme not found: {s}", .{name});
return;
};
switch (self.color_scheme) {
.dark => {
self.dark_theme = theme_;
if (self.dark_parsed_theme) |p| p.deinit();
self.dark_parsed_theme = parsed_theme;
self.dark_theme = theme_;
},
.light => {
self.light_theme = theme_;
if (self.light_parsed_theme) |p| p.deinit();
self.light_parsed_theme = parsed_theme;
self.light_theme = theme_;
},
}
self.set_terminal_style(&theme_);