22c47eeba21e2cdca73a1f108a1fe3cdb7545886

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

Message

Truncate long lines in Glamour output to fix layout

In some cases a few characters at the end of very long words like URLs
will now be dropped. This likely needs to be fixed upstream.

Diff

 1diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go
 2index 5d379d9ebe22faccfcca05ed525f35e90936012d..aad6a734ea943ac014f7bf8005a9e30b98f1adae 100644
 3--- a/tui/bubbles/repo/bubble.go
 4+++ b/tui/bubbles/repo/bubble.go
 5@@ -15,7 +15,6 @@ import (
 6 	"github.com/charmbracelet/glamour"
 7 	"github.com/charmbracelet/lipgloss"
 8 	"github.com/muesli/reflow/truncate"
 9-	"github.com/muesli/reflow/wordwrap"
10 	"github.com/muesli/reflow/wrap"
11 )
12 
13@@ -219,10 +218,15 @@ func (b *Bubble) glamourize(md string) (string, error) {
14 	if err != nil {
15 		return "", err
16 	}
17-	// Enforce a maximum width for cases when glamour lines run long.
18+	// For now, truncate long lines in Glamour that would otherwise break the
19+	// layout when wrapping. This is very likely due to #43 in Reflow, which
20+	// has to do with a bug in the way lines longer than the given width are
21+	// wrapped.
22 	//
23-	// TODO: This should utlimately be implemented as a Glamour option.
24-	mdt = wrap.String(wordwrap.String((mdt), w), w)
25+	//     https://github.com/muesli/reflow/issues/43
26+	//
27+	// TODO: solve this upstream in Glamour/Reflow.
28+	mdt = lipgloss.NewStyle().MaxWidth(w).Render(mdt)
29 	return mdt, nil
30 }
31