Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit a74f652

Browse files
meowgorithmkujtimiihoxha
authored andcommitted
chore: truncate version number if too long
1 parent 93e39fc commit a74f652

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

internal/tui/components/title/title.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/MakeNowJust/heredoc"
1010
"github.com/charmbracelet/lipgloss/v2"
11+
"github.com/charmbracelet/x/ansi"
1112
"github.com/charmbracelet/x/exp/slice"
1213
"github.com/lucasb-eyer/go-colorful"
1314
"github.com/rivo/uniseg"
@@ -50,6 +51,9 @@ func Render(version string, compact bool, o Opts) string {
5051
crush = b.String()
5152

5253
// Charm and version.
54+
metaRowGap := 1
55+
maxVersionWidth := crushWidth - lipgloss.Width(charm) - metaRowGap
56+
version = ansi.Truncate(version, maxVersionWidth, "…") // truncate version if too long.
5357
gap := max(0, crushWidth-lipgloss.Width(charm)-lipgloss.Width(version))
5458
metaRow := fg(o.CharmColor, charm) + strings.Repeat(" ", gap) + fg(o.VersionColor, version)
5559

0 commit comments

Comments
 (0)