fix(tui): attachment highlighting issues in messages (#1534)
This commit is contained in:
@@ -217,15 +217,27 @@ func renderText(
|
|||||||
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
|
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
|
||||||
text = ansi.WordwrapWc(text, width-6, " -")
|
text = ansi.WordwrapWc(text, width-6, " -")
|
||||||
|
|
||||||
// Build list of attachment filenames for highlighting
|
var result strings.Builder
|
||||||
|
lastEnd := int64(0)
|
||||||
|
|
||||||
|
// Apply highlighting to filenames and base style to rest of text
|
||||||
for _, filePart := range fileParts {
|
for _, filePart := range fileParts {
|
||||||
atFilename := "@" + filePart.Filename
|
highlight := base.Foreground(t.Secondary())
|
||||||
// Find and highlight complete @filename references
|
start, end := filePart.Source.Text.Start, filePart.Source.Text.End
|
||||||
highlightStyle := base.Foreground(t.Secondary())
|
|
||||||
text = strings.ReplaceAll(text, atFilename, highlightStyle.Render(atFilename))
|
if start > lastEnd {
|
||||||
|
result.WriteString(base.Render(text[lastEnd:start]))
|
||||||
|
}
|
||||||
|
result.WriteString(highlight.Render(text[start:end]))
|
||||||
|
|
||||||
|
lastEnd = end
|
||||||
}
|
}
|
||||||
|
|
||||||
content = base.Width(width - 6).Render(text)
|
if lastEnd < int64(len(text)) {
|
||||||
|
result.WriteString(base.Render(text[lastEnd:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
content = base.Width(width - 6).Render(result.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp := ts.
|
timestamp := ts.
|
||||||
|
|||||||
Reference in New Issue
Block a user