on main help sign in
fix: use visual width instead of byte length for text truncation (#1562)
edf6366Gustave-241021
internal/tui/components/chat/messages/renderer.go+1−1
@@ -1025,7 +1025,7 @@ func renderPlainContent(v *toolCallCmp, content string) string {
1025 }
1025 }
1026 ln = ansiext.Escape(ln)
1026 ln = ansiext.Escape(ln)
1027 ln = " " + ln
1027 ln = " " + ln
1028− if len(ln) > width {
1028+ if lipgloss.Width(ln) > width {
1029 ln = v.fit(ln, width)
1029 ln = v.fit(ln, width)
1030 }
1030 }
1031 out = append(out, t.S().Muted.
1031 out = append(out, t.S().Muted.
internal/tui/components/chat/messages/tool.go+3
@@ -790,6 +790,9 @@ func (m *toolCallCmp) textWidth() int {
790
790
791// fit truncates content to fit within the specified width with ellipsis
791// fit truncates content to fit within the specified width with ellipsis
792func (m *toolCallCmp) fit(content string, width int) string {
792func (m *toolCallCmp) fit(content string, width int) string {
793+ if lipgloss.Width(content) <= width {
794+ return content
795+ }
793 t := styles.CurrentTheme()
796 t := styles.CurrentTheme()
794 lineStyle := t.S().Muted
797 lineStyle := t.S().Muted
795 dots := lineStyle.Render("…")
798 dots := lineStyle.Render("…")