on main help sign in
fix(ui): padding in the view (#2107)
fd35a87Carlos Alexandro Becker
internal/ui/chat/tools.go+4−6
@@ -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)
589
589
590 bodyWidth := width - toolBodyLeftPaddingTotal
590 bodyWidth := width - toolBodyLeftPaddingTotal
591− codeWidth := bodyWidth - maxDigits - 4 // -4 for line number padding
591+ codeWidth := bodyWidth - maxDigits
592
592
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))
596
596
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(), "…")
599− }
600
599
601 codeLine := sty.Tool.ContentCodeLine.
600 codeLine := sty.Tool.ContentCodeLine.
602 Width(codeWidth).
601 Width(codeWidth).
603− PaddingLeft(2).
604 Render(ln)
602 Render(ln)
605
603
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)),
614 )
612 )
615 }
613 }
internal/ui/styles/styles.go+1−1
@@ -1115,7 +1115,7 @@ func DefaultStyles() Styles {
1115 // Content rendering - prepared styles that accept width parameter
1115 // Content rendering - prepared styles that accept width parameter
1116 s.Tool.ContentLine = s.Muted.Background(bgBaseLighter)
1116 s.Tool.ContentLine = s.Muted.Background(bgBaseLighter)
1117 s.Tool.ContentTruncation = s.Muted.Background(bgBaseLighter)
1117 s.Tool.ContentTruncation = s.Muted.Background(bgBaseLighter)
1118− s.Tool.ContentCodeLine = s.Base.Background(bgBase)
1118+ s.Tool.ContentCodeLine = s.Base.Background(bgBase).PaddingLeft(2)
1119 s.Tool.ContentCodeTruncation = s.Muted.Background(bgBase).PaddingLeft(2)
1119 s.Tool.ContentCodeTruncation = s.Muted.Background(bgBase).PaddingLeft(2)
1120 s.Tool.ContentCodeBg = bgBase
1120 s.Tool.ContentCodeBg = bgBase
1121 s.Tool.Body = base.PaddingLeft(2)
1121 s.Tool.Body = base.PaddingLeft(2)