diff --git a/pkg/tui/commands.go b/pkg/tui/commands.go index b4b0df4..48ebaa4 100644 --- a/pkg/tui/commands.go +++ b/pkg/tui/commands.go @@ -215,7 +215,7 @@ func renderIncident(m *model) tea.Cmd { return errMsg{err} } - content, err := renderIncidentMarkdown(t) + content, err := renderIncidentMarkdown(t, m.incidentViewer.Width) if err != nil { return errMsg{err} } diff --git a/pkg/tui/views.go b/pkg/tui/views.go index 434c9f2..8d77398 100644 --- a/pkg/tui/views.go +++ b/pkg/tui/views.go @@ -494,10 +494,17 @@ Details : {{ end }} ` -func renderIncidentMarkdown(content string) (string, error) { +func renderIncidentMarkdown(content string, width int) (string, error) { + // Glamour adds its own padding/margins, so we need to subtract some space + // to prevent content from extending beyond the viewport + adjustedWidth := width - 4 + if adjustedWidth < 40 { + adjustedWidth = 40 // Minimum reasonable width + } + renderer, err := glamour.NewTermRenderer( glamour.WithAutoStyle(), - glamour.WithWordWrap(0), + glamour.WithWordWrap(adjustedWidth), ) if err != nil { return "", err