summaryrefslogtreecommitdiff
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-06-24 20:23:30 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-24 20:27:24 +0900
commit8d81730ec2855d3d32a171f8b675430ffb4c4d59 (patch)
treebff2d9a2347b4b04e7d40c947f3744131856f8d1 /src/core.go
parent330a85c25c7e15d0913720530cb63d18d4bfe8ac (diff)
downloadfzf-8d81730ec2855d3d32a171f8b675430ffb4c4d59.tar.gz
with-nth: Do not trim trailing whitespaces with background colors
Example: echo -en ' \e[48;5;232mhello\e[48;5;147m ' | fzf --ansi --with-nth 1
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core.go b/src/core.go
index 46cd957a..7a762e3c 100644
--- a/src/core.go
+++ b/src/core.go
@@ -126,7 +126,17 @@ func Run(opts *Options) (int, error) {
return false
}
item.text, item.colors = ansiProcessor(stringBytes(transformed))
- item.text.TrimTrailingWhitespaces()
+
+ // We should not trim trailing whitespaces with background colors
+ var maxColorOffset int32
+ if item.colors != nil {
+ for _, ansi := range *item.colors {
+ if ansi.color.bg >= 0 {
+ maxColorOffset = util.Max32(maxColorOffset, ansi.offset[1])
+ }
+ }
+ }
+ item.text.TrimTrailingWhitespaces(int(maxColorOffset))
item.text.Index = itemIndex
item.origText = &data
itemIndex++