Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/tui/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading