From b25edc3e9367b4bd26d64e24dd819a72d5e48cf4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Feb 2026 13:04:31 -0800 Subject: [PATCH] termio: don't auto-generate palette if user didn't customize any This fixes the issue where our palette generation was changing our default palette. The default palette is based on some well known values chosen from various terminals and it was a bit jarring to have it change. We now only auto-generate the palette if the user has customized at least one entry. --- src/termio/Termio.zig | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/termio/Termio.zig b/src/termio/Termio.zig index 40af3cd94..dee58dc22 100644 --- a/src/termio/Termio.zig +++ b/src/termio/Termio.zig @@ -175,15 +175,25 @@ pub const DerivedConfig = struct { errdefer arena.deinit(); const alloc = arena.allocator(); - const palette: terminalpkg.color.Palette = if (config.@"palette-generate") - terminalpkg.color.generate256Color( - config.palette.value, - config.palette.mask, - config.background.toTerminalRGB(), - config.foreground.toTerminalRGB(), - ) - else - config.palette.value; + const palette: terminalpkg.color.Palette = palette: { + if (config.@"palette-generate") generate: { + if (config.palette.mask.findFirstSet() == null) { + // If the user didn't set any values manually, then + // we're using the default palette and we don't need + // to apply the generation code to it. + break :generate; + } + + break :palette terminalpkg.color.generate256Color( + config.palette.value, + config.palette.mask, + config.background.toTerminalRGB(), + config.foreground.toTerminalRGB(), + ); + } + + break :palette config.palette.value; + }; return .{ .palette = palette,