m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 06:43:47 -05:00

Show ellipsis for truncated labels

Close #4390
This commit is contained in:
Junegunn Choi
2025-05-17 11:24:53 +09:00
parent 894a1016bc
commit b27943423e
2 changed files with 38 additions and 3 deletions

View File

@@ -1235,9 +1235,14 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool)
return nil, 0
}
printFn := func(window tui.Window, limit int) {
if length > limit {
trimmedRunes, _ := t.trimRight(runes, limit)
window.CPrint(*color, string(trimmedRunes))
ellipsis := []rune{}
ellipsisWidth := 0
if !fill {
ellipsis, ellipsisWidth = util.Truncate(t.ellipsis, limit)
}
if length > limit-ellipsisWidth {
trimmedRunes, _ := t.trimRight(runes, limit-ellipsisWidth)
window.CPrint(*color, string(trimmedRunes)+string(ellipsis))
} else if fill {
window.CPrint(*color, util.RepeatToFill(text, length, limit))
} else {