From 54fd92b7ddb22647170110790391d39a1065a863 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 30 May 2025 20:33:21 +0900 Subject: --no-color: Keep ANSI attributes in the list Example: echo -e "\x1b[33;3mfoo \x1b[34;4mbar\x1b[m baz" | fzf --ansi --no-color --- src/result.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/result.go') diff --git a/src/result.go b/src/result.go index 3e4a81c0..acd7bb06 100644 --- a/src/result.go +++ b/src/result.go @@ -179,6 +179,9 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t var curr cellInfo = cellInfo{0, false, false, false} start := 0 ansiToColorPair := func(ansi ansiOffset, base tui.ColorPair) tui.ColorPair { + if !theme.Colored { + return tui.NewColorPair(-1, -1, ansi.color.attr).MergeAttr(base) + } fg := ansi.color.fg bg := ansi.color.bg if fg == -1 { @@ -200,7 +203,7 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t color = colBase.Merge(colMatch) } var url *url - if curr.color && theme.Colored { + if curr.color { ansi := itemColors[curr.index] url = ansi.color.url origColor := ansiToColorPair(ansi, colMatch) -- cgit v1.2.3