c053bde411d42223c83b5a37a7ccfe94e2e8a140

Author
Christian Rocha <christian@rocha.is>
Committer
Christian Rocha <christian@rocha.is>
Date

Message

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.

Diff

 1diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go
 2index f75d7c52cc887ae6fba51039b3606430b896b4d9..71b9f8507ba114db67d8433e1b665ffa7fd18f3b 100644
 3--- a/tui/bubbles/repo/bubble.go
 4+++ b/tui/bubbles/repo/bubble.go
 5@@ -117,11 +117,15 @@ func (b Bubble) headerView() string {
 6 	} else {
 7 		note = fmt.Sprintf("git clone %s", b.sshAddress())
 8 	}
 9-	noteStyle := b.styles.RepoNote.Copy().Width(
10-		b.width - b.widthMargin - lipgloss.Width(title) -
11-			b.styles.RepoTitleBox.GetHorizontalFrameSize(),
12-	)
13-	note = noteStyle.Render(note)
14+	noteWidth := b.width -
15+		b.widthMargin -
16+		lipgloss.Width(title) -
17+		b.styles.RepoTitleBox.GetHorizontalFrameSize()
18+	// Hard-wrap the clone command only, without the usual word-wrapping. since
19+	// a long repo name isn't going to be a series of space-separated "words",
20+	// we'll always want it to be perfectly hard-wrapped.
21+	note = wrap.String(note, noteWidth-b.styles.RepoNote.GetHorizontalFrameSize())
22+	note = b.styles.RepoNote.Copy().Width(noteWidth).Render(note)
23 
24 	// Render borders on name and command
25 	height := max(lipgloss.Height(title), lipgloss.Height(note))