@@ -588,19 +588,17 @@ func toolOutputCodeContent(sty *styles.Styles, path, content string, offset, wid
588 numFmt := fmt.Sprintf("%%%dd", maxDigits)
588 numFmt := fmt.Sprintf("%%%dd", maxDigits)
590 bodyWidth := width - toolBodyLeftPaddingTotal
590 bodyWidth := width - toolBodyLeftPaddingTotal
591− codeWidth := bodyWidth - maxDigits - 4 // -4 for line number padding
591+ codeWidth := bodyWidth - maxDigits
593 var out []string
593 var out []string
594 for i, ln := range highlightedLines {
594 for i, ln := range highlightedLines {
595 lineNum := sty.Tool.ContentLineNumber.Render(fmt.Sprintf(numFmt, i+1+offset))
595 lineNum := sty.Tool.ContentLineNumber.Render(fmt.Sprintf(numFmt, i+1+offset))
597− if lipgloss.Width(ln) > codeWidth {
597+ // Truncate accounting for padding that will be added.
598− ln = ansi.Truncate(ln, codeWidth, "…")
598+ ln = ansi.Truncate(ln, codeWidth-sty.Tool.ContentCodeLine.GetHorizontalPadding(), "…")
601 codeLine := sty.Tool.ContentCodeLine.
600 codeLine := sty.Tool.ContentCodeLine.
602 Width(codeWidth).
601 Width(codeWidth).
604 Render(ln)
602 Render(ln)
606 out = append(out, lipgloss.JoinHorizontal(lipgloss.Left, lineNum, codeLine))
604 out = append(out, lipgloss.JoinHorizontal(lipgloss.Left, lineNum, codeLine))
@@ -609,7 +607,7 @@ func toolOutputCodeContent(sty *styles.Styles, path, content string, offset, wid
609 // Add truncation message if needed.
607 // Add truncation message if needed.
610 if len(lines) > maxLines && !expanded {
608 if len(lines) > maxLines && !expanded {
611 out = append(out, sty.Tool.ContentCodeTruncation.
609 out = append(out, sty.Tool.ContentCodeTruncation.
612− Width(bodyWidth).
610+ Width(width).
613 Render(fmt.Sprintf(assistantMessageTruncateFormat, len(lines)-maxLines)),
611 Render(fmt.Sprintf(assistantMessageTruncateFormat, len(lines)-maxLines)),