Skip to content
Myr

Handle ambiguous emoji width

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #3588

authored by Junegunn Choi · committed by Junegunn Choi · parent 59fb652 · Browse files · 3 files+15 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−3 removed

  • other:+15 added−3 removed

3 files+15 added−3 removed

modified:src/util/util_test.go+12 added
162 unmodified lines
163 if overflowIdx != args[2] {164 t.Errorf("Expected overflow index: %d, actual: %d", args[2], overflowIdx)165 }166 }167 for _, input := range []struct {168 s string169 w int170 }{171 {"▶", 1},172 {"▶️", 2},173 } {174 width, _ := RunesWidth([]rune(input.s), 0, 0, 100)175 if width != input.w {176 t.Errorf("Expected width of %s: %d, actual: %d", input.s, input.w, width)177 }178 }179}180181func TestTruncate(t *testing.T) {182 truncated, width := Truncate("가나다라마", 7)
23 unmodified lines
modified:go.mod+1 added-1 removed
1module github.com/junegunn/fzf23require (4 github.com/gdamore/tcell/v2 v2.5.45 github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab485 github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec546 github.com/mattn/go-isatty v0.0.177 github.com/mattn/go-shellwords v1.0.128 github.com/rivo/uniseg v0.4.49 github.com/saracen/walker v0.1.3
13 unmodified lines
modified:go.sum+2 added-2 removed
1github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=2github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=3github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k=4github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw=5github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 h1:546WmTZE4BUDJXhKlsaqhgdAPt+yWp82cNkzJxsvVDQ=6github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w=5github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec54 h1:eBbXiL4VPihi5C8DhESYtax8HYfgCDUkzVYigADhkzU=6github.com/junegunn/go-runewidth v0.0.15-0.20240119074001-7d2ea235ec54/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w=7github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=8github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=9github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=10github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
42 unmodified lines