@@ -588,19 +588,17 @@ func toolOutputCodeContent(sty *styles.Styles, path, content string, offset, wid
588588 numFmt := fmt.Sprintf("%%%dd", maxDigits)
589589
590590 bodyWidth := width - toolBodyLeftPaddingTotal
591− codeWidth := bodyWidth - maxDigits - 4 // -4 for line number padding
591+ codeWidth := bodyWidth - maxDigits
592592
593593 var out []string
594594 for i, ln := range highlightedLines {
595595 lineNum := sty.Tool.ContentLineNumber.Render(fmt.Sprintf(numFmt, i+1+offset))
596596
597− if lipgloss.Width(ln) > codeWidth {
598− ln = ansi.Truncate(ln, codeWidth, "…")
599− }
597+ // Truncate accounting for padding that will be added.
598+ ln = ansi.Truncate(ln, codeWidth-sty.Tool.ContentCodeLine.GetHorizontalPadding(), "…")
600599
601600 codeLine := sty.Tool.ContentCodeLine.
602601 Width(codeWidth).
603− PaddingLeft(2).
604602 Render(ln)
605603
606604 out = append(out, lipgloss.JoinHorizontal(lipgloss.Left, lineNum, codeLine))
@@ -609,7 +607,7 @@ func toolOutputCodeContent(sty *styles.Styles, path, content string, offset, wid
609607 // Add truncation message if needed.
610608 if len(lines) > maxLines && !expanded {
611609 out = append(out, sty.Tool.ContentCodeTruncation.
612− Width(bodyWidth).
610+ Width(width).
613611 Render(fmt.Sprintf(assistantMessageTruncateFormat, len(lines)-maxLines)),
614612 )
615613 }