mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-03 16:05:00 +01:00
fix: attachment highlighting (#1427)
This commit is contained in:
@@ -182,6 +182,7 @@ func renderText(
|
|||||||
showToolDetails bool,
|
showToolDetails bool,
|
||||||
width int,
|
width int,
|
||||||
extra string,
|
extra string,
|
||||||
|
fileParts []opencode.FilePart,
|
||||||
toolCalls ...opencode.ToolPart,
|
toolCalls ...opencode.ToolPart,
|
||||||
) string {
|
) string {
|
||||||
t := theme.CurrentTheme()
|
t := theme.CurrentTheme()
|
||||||
@@ -197,19 +198,15 @@ func renderText(
|
|||||||
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, " -")
|
text = ansi.WordwrapWc(text, width-6, " -")
|
||||||
lines := strings.Split(text, "\n")
|
|
||||||
for i, line := range lines {
|
// Build list of attachment filenames for highlighting
|
||||||
words := strings.Fields(line)
|
for _, filePart := range fileParts {
|
||||||
for i, word := range words {
|
atFilename := "@" + filePart.Filename
|
||||||
if strings.HasPrefix(word, "@") {
|
// Find and highlight complete @filename references
|
||||||
words[i] = base.Foreground(t.Secondary()).Render(word + " ")
|
highlightStyle := base.Foreground(t.Secondary())
|
||||||
} else {
|
text = strings.ReplaceAll(text, atFilename, highlightStyle.Render(atFilename))
|
||||||
words[i] = base.Render(word + " ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lines[i] = strings.Join(words, "")
|
|
||||||
}
|
}
|
||||||
text = strings.Join(lines, "\n")
|
|
||||||
content = base.Width(width - 6).Render(text)
|
content = base.Width(width - 6).Render(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
|||||||
m.showToolDetails,
|
m.showToolDetails,
|
||||||
width,
|
width,
|
||||||
files,
|
files,
|
||||||
|
fileParts,
|
||||||
)
|
)
|
||||||
content = lipgloss.PlaceHorizontal(
|
content = lipgloss.PlaceHorizontal(
|
||||||
m.width,
|
m.width,
|
||||||
@@ -424,6 +425,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
|||||||
m.showToolDetails,
|
m.showToolDetails,
|
||||||
width,
|
width,
|
||||||
"",
|
"",
|
||||||
|
[]opencode.FilePart{},
|
||||||
toolCallParts...,
|
toolCallParts...,
|
||||||
)
|
)
|
||||||
content = lipgloss.PlaceHorizontal(
|
content = lipgloss.PlaceHorizontal(
|
||||||
@@ -443,6 +445,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
|||||||
m.showToolDetails,
|
m.showToolDetails,
|
||||||
width,
|
width,
|
||||||
"",
|
"",
|
||||||
|
[]opencode.FilePart{},
|
||||||
toolCallParts...,
|
toolCallParts...,
|
||||||
)
|
)
|
||||||
content = lipgloss.PlaceHorizontal(
|
content = lipgloss.PlaceHorizontal(
|
||||||
|
|||||||
Reference in New Issue
Block a user