From 8d81730ec2855d3d32a171f8b675430ffb4c4d59 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 24 Jun 2025 20:23:30 +0900 Subject: 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 --- src/util/chars.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/util/chars.go') diff --git a/src/util/chars.go b/src/util/chars.go index e5234303..b1a03fa9 100644 --- a/src/util/chars.go +++ b/src/util/chars.go @@ -184,9 +184,10 @@ func (chars *Chars) TrailingWhitespaces() int { return whitespaces } -func (chars *Chars) TrimTrailingWhitespaces() { +func (chars *Chars) TrimTrailingWhitespaces(maxIndex int) { whitespaces := chars.TrailingWhitespaces() - chars.slice = chars.slice[0 : len(chars.slice)-whitespaces] + end := len(chars.slice) - whitespaces + chars.slice = chars.slice[0:Max(end, maxIndex)] } func (chars *Chars) TrimSuffix(runes []rune) { -- cgit v1.2.3