From aae354c9513c8f36e770ff805e75585fb152593c Mon Sep 17 00:00:00 2001 From: adamdotdevin <2363879+adamdottv@users.noreply.github.com> Date: Tue, 12 Aug 2025 13:03:26 -0500 Subject: [PATCH] fix: word wrapping with hyphens --- packages/tui/internal/components/chat/message.go | 4 +++- packages/tui/internal/util/file.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index 1bbf3c5c..2d762dfa 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -325,7 +325,9 @@ func renderText( // wrap styled text styledText := result.String() - wrappedText := ansi.WordwrapWc(styledText, width-6, " -") + styledText = strings.ReplaceAll(styledText, "-", "\u2011") + wrappedText := ansi.WordwrapWc(styledText, width-6, " ") + wrappedText = strings.ReplaceAll(wrappedText, "\u2011", "-") content = base.Width(width - 6).Render(wrappedText) } diff --git a/packages/tui/internal/util/file.go b/packages/tui/internal/util/file.go index b079f24c..943f784f 100644 --- a/packages/tui/internal/util/file.go +++ b/packages/tui/internal/util/file.go @@ -85,6 +85,7 @@ func Extension(path string) string { func ToMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) string { r := styles.GetMarkdownRenderer(width-6, backgroundColor) content = strings.ReplaceAll(content, RootPath+"/", "") + content = strings.ReplaceAll(content, "-", "\u2011") rendered, _ := r.Render(content) lines := strings.Split(rendered, "\n") @@ -105,5 +106,6 @@ func ToMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) } } content = strings.Join(lines, "\n") + content = strings.ReplaceAll(content, "\u2011", "-") return strings.TrimSuffix(content, "\n") }