From aa259fdc1910acbbeef4562bf41a762ecb428828 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 21 Oct 2025 19:49:43 +0900 Subject: [PATCH] Fix regression in `--no-color` / `NO_COLOR` theme Fix #4561 --- CHANGELOG.md | 14 ++++++++++---- src/options.go | 4 +++- src/tui/tui.go | 7 ++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65abb54d..c4153831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +0.66.1 +------ +- Bug fixes + - Fixed a bug preventing 'ctrl-h' from being bound to an action (#4556) + - Fixed `--no-color` / `NO_COLOR` theme + 0.66.0 ------ @@ -35,10 +41,10 @@ This version introduces many new features centered around the new "raw" mode. This version introduces a new "raw" mode (named so because it shows the list "unfiltered"). In raw mode, non-matching items stay in their original positions, -but appear dimmed. This allows you see surrounding items of a match and better -understand the context of it. You can enable raw mode by default with `--raw`, -but it's often more useful when toggled dynamically with the `toggle-raw` -action. +but appear dimmed. This allows you to see the surrounding items of a match and +better understand the context of it. You can enable raw mode by default with +`--raw`, but it's often more useful when toggled dynamically with the +`toggle-raw` action. ```sh tree | fzf --reverse --bind alt-r:toggle-raw diff --git a/src/options.go b/src/options.go index e9cc0127..2ae004ed 100644 --- a/src/options.go +++ b/src/options.go @@ -673,9 +673,10 @@ func defaultPreviewOpts(command string) previewOpts { } func defaultOptions() *Options { - var theme *tui.ColorTheme + var theme, baseTheme *tui.ColorTheme if os.Getenv("NO_COLOR") != "" { theme = tui.NoColorTheme + baseTheme = tui.NoColorTheme } else { theme = tui.EmptyTheme } @@ -703,6 +704,7 @@ func defaultOptions() *Options { Ansi: false, Mouse: true, Theme: theme, + BaseTheme: baseTheme, Black: false, Bold: true, MinHeight: -10, diff --git a/src/tui/tui.go b/src/tui/tui.go index 4e285451..49b828f4 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -295,8 +295,9 @@ func (a ColorAttr) IsColorDefined() bool { } func (a ColorAttr) IsAttrDefined() bool { - return a.Attr != AttrUndefined + return a.Attr&^BoldForce != AttrUndefined } + func (a ColorAttr) IsUndefined() bool { return !a.IsColorDefined() && !a.IsAttrDefined() } @@ -1156,12 +1157,12 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, boldify bool, forceBlac // e.g. fzf --delimiter / --nth -1 --color fg:dim,nth:regular current := theme.Current if !baseTheme.Colored && current.IsUndefined() { - current.Attr = Reverse + current.Attr |= Reverse } theme.Current = theme.Fg.Merge(o(baseTheme.Current, current)) currentMatch := theme.CurrentMatch if !baseTheme.Colored && currentMatch.IsUndefined() { - currentMatch.Attr = Reverse | Underline + currentMatch.Attr |= Reverse | Underline } theme.CurrentMatch = o(baseTheme.CurrentMatch, currentMatch) theme.Spinner = o(baseTheme.Spinner, theme.Spinner)