From b8a0ecca981b59b4fd7f6a0c07f60790aa3fefbb Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 6 Aug 2025 05:17:35 -0500 Subject: [PATCH] fix: highlight after text wrap (#1640) --- packages/tui/internal/components/chat/message.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index ec908d5c..aba758c1 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -223,12 +223,11 @@ func renderText( case opencode.UserMessage: ts = time.UnixMilli(int64(casted.Time.Created)) base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor) - text = ansi.WordwrapWc(text, width-6, " -") var result strings.Builder lastEnd := int64(0) - // Apply highlighting to filenames and base style to rest of text + // Apply highlighting to filenames and base style to rest of text BEFORE wrapping textLen := int64(len(text)) for _, filePart := range fileParts { highlight := base.Foreground(t.Secondary()) @@ -254,7 +253,11 @@ func renderText( if lastEnd < textLen { result.WriteString(base.Render(text[lastEnd:])) } - content = base.Width(width - 6).Render(result.String()) + + // wrap styled text + styledText := result.String() + wrappedText := ansi.WordwrapWc(styledText, width-6, " -") + content = base.Width(width - 6).Render(wrappedText) } timestamp := ts.