diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-19 16:41:50 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-19 16:41:50 +0900 |
commit | 8a2c41e183386ed6f073c6f41b2c580799553ae3 (patch) | |
tree | 3f855197387db9b1278bde117a767ce9ed9c0de2 | |
parent | 59fb65293a306dd685c1098d73eb62e5b0892eb8 (diff) |
Handle ambiguous emoji width
Fix #3588
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | src/util/util_test.go | 12 |
3 files changed, 15 insertions, 3 deletions
@@ -2,7 +2,7 @@ module github.com/junegunn/fzf require ( github.com/gdamore/tcell/v2 v2.5.4 - github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 + github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec54 github.com/mattn/go-isatty v0.0.17 github.com/mattn/go-shellwords v1.0.12 github.com/rivo/uniseg v0.4.4 @@ -2,8 +2,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k= github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw= -github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 h1:546WmTZE4BUDJXhKlsaqhgdAPt+yWp82cNkzJxsvVDQ= -github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w= +github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec54 h1:eBbXiL4VPihi5C8DhESYtax8HYfgCDUkzVYigADhkzU= +github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec54/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= diff --git a/src/util/util_test.go b/src/util/util_test.go index 42a66636..af0762b5 100644 --- a/src/util/util_test.go +++ b/src/util/util_test.go @@ -164,6 +164,18 @@ func TestRunesWidth(t *testing.T) { t.Errorf("Expected overflow index: %d, actual: %d", args[2], overflowIdx) } } + for _, input := range []struct { + s string + w int + }{ + {"▶", 1}, + {"▶️", 2}, + } { + width, _ := RunesWidth([]rune(input.s), 0, 0, 100) + if width != input.w { + t.Errorf("Expected width of %s: %d, actual: %d", input.s, input.w, width) + } + } } func TestTruncate(t *testing.T) { |