From 22c47eeba21e2cdca73a1f108a1fe3cdb7545886 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 22 Sep 2021 16:24:21 -0400 Subject: [PATCH] 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. --- tui/bubbles/repo/bubble.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go index 5d379d9eb..aad6a734e 100644 --- a/tui/bubbles/repo/bubble.go +++ b/tui/bubbles/repo/bubble.go @@ -15,7 +15,6 @@ import ( "github.com/charmbracelet/glamour" "github.com/charmbracelet/lipgloss" "github.com/muesli/reflow/truncate" - "github.com/muesli/reflow/wordwrap" "github.com/muesli/reflow/wrap" ) @@ -219,10 +218,15 @@ func (b *Bubble) glamourize(md string) (string, error) { if err != nil { return "", err } - // Enforce a maximum width for cases when glamour lines run long. + // For now, truncate long lines in Glamour that would otherwise break the + // layout when wrapping. This is very likely due to #43 in Reflow, which + // has to do with a bug in the way lines longer than the given width are + // wrapped. // - // TODO: This should utlimately be implemented as a Glamour option. - mdt = wrap.String(wordwrap.String((mdt), w), w) + // https://github.com/muesli/reflow/issues/43 + // + // TODO: solve this upstream in Glamour/Reflow. + mdt = lipgloss.NewStyle().MaxWidth(w).Render(mdt) return mdt, nil }