From 8a2c41e183386ed6f073c6f41b2c580799553ae3 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 19 Jan 2024 16:41:50 +0900 Subject: Handle ambiguous emoji width Fix #3588 --- src/util/util_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3