From 66fb03a29ae27791a51a112cd02a51f342de50ef Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Mon, 22 Jan 2024 15:33:09 -0500 Subject: [PATCH] perf: use `uniseg.StringWidth` --- go.mod | 4 +--- go.sum | 6 ++---- style.go | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 7973f12..c400ede 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,6 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-isatty v0.0.19 - github.com/mattn/go-runewidth v0.0.14 + github.com/rivo/uniseg v0.4.4 golang.org/x/sys v0.10.0 ) - -require github.com/rivo/uniseg v0.2.0 // indirect diff --git a/go.sum b/go.sum index 00334b4..02e1a7d 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/style.go b/style.go index 83b0b4d..dedc1f9 100644 --- a/style.go +++ b/style.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/mattn/go-runewidth" + "github.com/rivo/uniseg" ) // Sequence definitions. @@ -122,5 +122,5 @@ func (t Style) CrossOut() Style { // Width returns the width required to print all runes in Style. func (t Style) Width() int { - return runewidth.StringWidth(t.string) + return uniseg.StringWidth(t.string) }