on main help sign in
fix: use visual width instead of byte length for text truncation (#1562)
commitedf63666b85386e757b8d5cbbd41d5dcefe65d61 authorGustave-241021 <2909789120@qq.com> dateMon 8 Dec 2025, 22:19 (1 year ago) parentda5c283
2 files changed+4−1
internal/tui/components/chat/messages/renderer.go+1−1 internal/tui/components/chat/messages/tool.go+3
internal/tui/components/chat/messages/renderer.go+1−1
@@ -1025,7 +1025,7 @@ func renderPlainContent(v *toolCallCmp, content string) string {
10251025 }
10261026 ln = ansiext.Escape(ln)
10271027 ln = " " + ln
1028− if len(ln) > width {
1028+ if lipgloss.Width(ln) > width {
10291029 ln = v.fit(ln, width)
10301030 }
10311031 out = append(out, t.S().Muted.
internal/tui/components/chat/messages/tool.go+3
@@ -790,6 +790,9 @@ func (m *toolCallCmp) textWidth() int {
790790
791791// fit truncates content to fit within the specified width with ellipsis
792792func (m *toolCallCmp) fit(content string, width int) string {
793+ if lipgloss.Width(content) <= width {
794+ return content
795+ }
793796 t := styles.CurrentTheme()
794797 lineStyle := t.S().Muted
795798 dots := lineStyle.Render("…")