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 /src | |
parent | 59fb65293a306dd685c1098d73eb62e5b0892eb8 (diff) |
Handle ambiguous emoji width
Fix #3588
Diffstat (limited to 'src')
-rw-r--r-- | src/util/util_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
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) { |