termio: don't auto-generate palette if user didn't customize any (#10802)

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.
pull/10804/head
Mitchell Hashimoto 2026-02-17 13:08:26 -08:00 committed by GitHub
commit 41cea500f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 9 deletions

View File

@ -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,