Skip to content

Commit

Permalink
perf: use uniseg.StringWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Jan 22, 2024
1 parent 83f6379 commit 519f260
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion go.mod
Expand Up @@ -2,4 +2,7 @@ module github.com/muesli/reflow

go 1.13

require github.com/mattn/go-runewidth v0.0.14
require (
github.com/mattn/go-runewidth v0.0.14
github.com/rivo/uniseg v0.4.4
)
3 changes: 2 additions & 1 deletion go.sum
@@ -1,4 +1,5 @@
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=
4 changes: 2 additions & 2 deletions padding/padding.go
Expand Up @@ -5,8 +5,8 @@ import (
"io"
"strings"

"github.com/mattn/go-runewidth"
"github.com/muesli/reflow/ansi"
"github.com/rivo/uniseg"
)

type PaddingFunc func(w io.Writer)
Expand Down Expand Up @@ -71,7 +71,7 @@ func (w *Writer) Write(b []byte) (int, error) {
w.ansi = false
}
} else {
w.lineLen += runewidth.StringWidth(string(c))
w.lineLen += uniseg.StringWidth(string(c))

if c == '\n' {
// end of current line
Expand Down

0 comments on commit 519f260

Please sign in to comment.