Skip to content

Commit 4b97941

Browse files
committed
Fix line wrapping when multi-cell runes are involved
1 parent 707d64a commit 4b97941

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

view.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,10 @@ func lineWrap(line []cell, columns int) [][]cell {
15231523
}
15241524
// Either way, continue *after* the break
15251525
offset = lastWhitespaceIndex + 1
1526-
n = i - offset + 1
1526+
n = 0
1527+
for _, c := range line[offset : i+1] {
1528+
n += runewidth.RuneWidth(c.chr)
1529+
}
15271530
} else {
15281531
// in this case we're breaking mid-word
15291532
lines = append(lines, line[offset:i])

view_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,10 @@ func TestLineWrap(t *testing.T) {
241241
line: "🐤🐤🐤 🐝🐝 🙉 🦊🦊🦊-🐬🐬 🦢🦢",
242242
columns: 9,
243243
expected: []string{
244-
/* EXPECTED:
245244
"🐤🐤🐤",
246245
"🐝🐝 🙉",
247246
"🦊🦊🦊-",
248247
"🐬🐬 🦢🦢",
249-
ACTUAL: */
250-
"🐤🐤🐤",
251-
"🐝🐝 🙉",
252-
"🦊🦊🦊-🐬🐬",
253-
"🦢🦢",
254248
},
255249
},
256250
{

0 commit comments

Comments
 (0)