@@ -23,6 +23,7 @@ import (
2323 "github.com/charmbracelet/crush/internal/config"
2424 "github.com/charmbracelet/crush/internal/csync"
2525 "github.com/charmbracelet/crush/internal/fsext"
26+ "github.com/charmbracelet/x/ansi"
2627)
2728
2829// regexCache provides thread-safe caching of compiled regex patterns
@@ -161,8 +162,8 @@ func NewGrepTool(workingDir string, config config.ToolGrep) fantasy.AgentTool {
161162 }
162163 if match.lineNum > 0 {
163164 lineText := match.lineText
164− if len(lineText) > maxGrepContentWidth {
165− lineText = lineText[:maxGrepContentWidth] + "..."
165+ if ansi.StringWidth(lineText) > maxGrepContentWidth {
166+ lineText = ansi.Truncate(lineText, maxGrepContentWidth, "...")
166167 }
167168 if match.charNum > 0 {
168169 fmt.Fprintf(&output, " Line %d, Char %d: %s\n", match.lineNum, match.charNum, lineText)