Skip to content

Commit 7ec784e

Browse files
committed
Add test demonstrating wrong truncation of branch names containing non-ASCII characters
1 parent 93af001 commit 7ec784e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/gui/presentation/branches_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ func Test_getBranchDisplayStrings(t *testing.T) {
4343
showDivergenceCfg: "none",
4444
expected: []string{"1m", "branch_name"},
4545
},
46+
{
47+
branch: &models.Branch{Name: "🍉_special_char", Recency: "1m"},
48+
itemOperation: types.ItemOperationNone,
49+
fullDescription: false,
50+
viewWidth: 19,
51+
useIcons: false,
52+
checkedOutByWorktree: false,
53+
showDivergenceCfg: "none",
54+
expected: []string{"1m", "🍉_special_c…"}, // truncated, but shouldn't
55+
},
4656
{
4757
branch: &models.Branch{Name: "branch_name", Recency: "1m"},
4858
itemOperation: types.ItemOperationNone,
@@ -184,6 +194,16 @@ func Test_getBranchDisplayStrings(t *testing.T) {
184194
showDivergenceCfg: "none",
185195
expected: []string{"1m", "branch_na…"},
186196
},
197+
{
198+
branch: &models.Branch{Name: "🍉_special_char", Recency: "1m"},
199+
itemOperation: types.ItemOperationNone,
200+
fullDescription: false,
201+
viewWidth: 18,
202+
useIcons: false,
203+
checkedOutByWorktree: false,
204+
showDivergenceCfg: "none",
205+
expected: []string{"1m", "🍉_special_…"}, // truncated two runes too much
206+
},
187207
{
188208
branch: &models.Branch{Name: "branch_name", Recency: "1m"},
189209
itemOperation: types.ItemOperationNone,

0 commit comments

Comments
 (0)