From 88ed363d0bd304e0a0f98e5d3877554d2e4513de Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Mon, 29 Apr 2024 11:37:24 -0400 Subject: [PATCH] feat: use `uniseg` to calculate `DisplayWidth` --- pkg/text/text.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/text/text.go b/pkg/text/text.go index af4e979..c68d157 100644 --- a/pkg/text/text.go +++ b/pkg/text/text.go @@ -8,8 +8,8 @@ import ( "time" "unicode" - "github.com/muesli/reflow/ansi" "github.com/muesli/reflow/truncate" + "github.com/rivo/uniseg" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" @@ -33,7 +33,7 @@ func Indent(s, indent string) string { // DisplayWidth calculates what the rendered width of string s will be. func DisplayWidth(s string) int { - return ansi.PrintableRuneWidth(s) + return uniseg.StringWidth(s) } // Truncate returns a copy of the string s that has been shortened to fit the maximum display width.