Do not apply 'nth' attributes to trailing whitespaces

# foo  bar
    # -----    <- previously underlined trailing whitespace
    # ---      <- with the fix, trailing whitespace is excluded
    fzf --color nth:underline --nth 1 <<< 'foo  bar'
This commit is contained in:
Junegunn Choi
2025-05-30 19:43:10 +09:00
parent c7ee3b833f
commit 1721e6a1ed

View File

@@ -3044,7 +3044,8 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
}
for _, token := range tokens {
start := token.prefixLength
end := start + int32(token.text.Length())
length := token.text.Length() - token.text.TrailingWhitespaces()
end := start + int32(length)
nthOffsets = append(nthOffsets, Offset{int32(start), int32(end)})
}
sort.Sort(ByOrder(nthOffsets))