fix: highlight after text wrap (#1640)
This commit is contained in:
parent
ad10d3a126
commit
b8a0ecca98
1 changed files with 6 additions and 3 deletions
|
|
@ -223,12 +223,11 @@ func renderText(
|
||||||
case opencode.UserMessage:
|
case opencode.UserMessage:
|
||||||
ts = time.UnixMilli(int64(casted.Time.Created))
|
ts = time.UnixMilli(int64(casted.Time.Created))
|
||||||
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
|
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
|
||||||
text = ansi.WordwrapWc(text, width-6, " -")
|
|
||||||
|
|
||||||
var result strings.Builder
|
var result strings.Builder
|
||||||
lastEnd := int64(0)
|
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))
|
textLen := int64(len(text))
|
||||||
for _, filePart := range fileParts {
|
for _, filePart := range fileParts {
|
||||||
highlight := base.Foreground(t.Secondary())
|
highlight := base.Foreground(t.Secondary())
|
||||||
|
|
@ -254,7 +253,11 @@ func renderText(
|
||||||
if lastEnd < textLen {
|
if lastEnd < textLen {
|
||||||
result.WriteString(base.Render(text[lastEnd:]))
|
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.
|
timestamp := ts.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue