From c053bde411d42223c83b5a37a7ccfe94e2e8a140 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 22 Sep 2021 15:04:08 -0400 Subject: [PATCH] Hard-wrap the clone command only for better output (no word-wrapping) Clone commands will pretty much need to hard-wrap only. As such, this commit provides better rendering in that respect and seemingly fixes what appears to be a related bug with regard to heights. --- tui/bubbles/repo/bubble.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go index f75d7c52cc887ae6fba51039b3606430b896b4d9..71b9f8507ba114db67d8433e1b665ffa7fd18f3b 100644 --- a/tui/bubbles/repo/bubble.go +++ b/tui/bubbles/repo/bubble.go @@ -117,11 +117,15 @@ func (b Bubble) headerView() string { } else { note = fmt.Sprintf("git clone %s", b.sshAddress()) } - noteStyle := b.styles.RepoNote.Copy().Width( - b.width - b.widthMargin - lipgloss.Width(title) - - b.styles.RepoTitleBox.GetHorizontalFrameSize(), - ) - note = noteStyle.Render(note) + noteWidth := b.width - + b.widthMargin - + lipgloss.Width(title) - + b.styles.RepoTitleBox.GetHorizontalFrameSize() + // Hard-wrap the clone command only, without the usual word-wrapping. since + // a long repo name isn't going to be a series of space-separated "words", + // we'll always want it to be perfectly hard-wrapped. + note = wrap.String(note, noteWidth-b.styles.RepoNote.GetHorizontalFrameSize()) + note = b.styles.RepoNote.Copy().Width(noteWidth).Render(note) // Render borders on name and command height := max(lipgloss.Height(title), lipgloss.Height(note))