From 4228f7506d72a0a381c011539de17635f578f7d7 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 29 Jan 2026 15:33:33 -0500 Subject: [PATCH] fix: slice string at the grapheme level, not byte level --- internal/ui/dialog/sessions_item.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/ui/dialog/sessions_item.go b/internal/ui/dialog/sessions_item.go index 119d3efb9cba1ee0a700b0b4bc22fee94289af76..6b1fe27580bba28aa02b06e2738e1882b7144107 100644 --- a/internal/ui/dialog/sessions_item.go +++ b/internal/ui/dialog/sessions_item.go @@ -148,7 +148,7 @@ func renderItem(t ListIemStyles, title string, info string, focused bool, width for _, rng := range ranges { start, stop := bytePosToVisibleCharPos(title, rng) if start > lastPos { - parts = append(parts, title[lastPos:start]) + parts = append(parts, ansi.Cut(title, lastPos, start)) } // NOTE: We're using [ansi.Style] here instead of [lipglosStyle] // because we can control the underline start and stop more @@ -157,13 +157,13 @@ func renderItem(t ListIemStyles, title string, info string, focused bool, width // with other style parts = append(parts, ansi.NewStyle().Underline(true).String(), - title[start:stop+1], + ansi.Cut(title, start, stop+1), ansi.NewStyle().Underline(false).String(), ) lastPos = stop + 1 } - if lastPos < len(title) { - parts = append(parts, title[lastPos:]) + if lastPos < ansi.StringWidth(title) { + parts = append(parts, ansi.Cut(title, lastPos, ansi.StringWidth(title))) } content = strings.Join(parts, "")