mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 23:33:39 -05:00
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
This commit is contained in:
12
src/core.go
12
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++
|
||||
|
||||
Reference in New Issue
Block a user