From d61ea80f98e66170220dde6ab8f8559c105f9551 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 13 Sep 2021 13:34:20 -0400 Subject: [PATCH] Truncate repo names in repo detail header if needed --- tui/bubbles/repo/bubble.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go index 573c869dc52ac1f867816ae2c7e85c1b426f2c2b..84a77caa10e79b257bd98a6d13cd98608ae8a7d1 100644 --- a/tui/bubbles/repo/bubble.go +++ b/tui/bubbles/repo/bubble.go @@ -12,11 +12,15 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/glamour" "github.com/charmbracelet/lipgloss" + "github.com/muesli/reflow/truncate" "github.com/muesli/reflow/wordwrap" "github.com/muesli/reflow/wrap" ) -const glamourMaxWidth = 120 +const ( + glamourMaxWidth = 120 + repoNameMaxWidth = 32 +) type ErrMsg struct { Error error @@ -103,7 +107,7 @@ func (b Bubble) headerView() string { ns = ns.Copy().BorderForeground(b.styles.ActiveBorderColor) } var gc string - n := b.name + n := truncate.StringWithTail(b.name, repoNameMaxWidth, "…") if n == "config" { n = "Home" } else {