summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-05-17 11:24:53 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-05-17 11:25:15 +0900
commitb27943423e1cde31a7f27c7b031d7fa108cf9c14 (patch)
treeb7feebbd92669131ea8af730dd8c62c2b71f7344 /src
parent894a1016bccfcb3c68707b798a73e99b78e97bd4 (diff)
downloadfzf-b27943423e1cde31a7f27c7b031d7fa108cf9c14.tar.gz
Show ellipsis for truncated labels
Close #4390
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/terminal.go b/src/terminal.go
index a79d166f..094d3c91 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -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 {