Skip to content

Commit 24746d5

Browse files
committed
Fix breaking lines at a space in the last column
I don't understand what the `&& lastWhitespaceIndex+1 != i` condition was added for; I can't see a reason for it. Removing it fixes the problem. Granted, it's not a serious problem, not even a cosmetic one as the space is not visible. Still, it's cleaner and less confusing this way.
1 parent a05f244 commit 24746d5

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ func lineWrap(line []cell, columns int) [][]cell {
15121512
lines = append(lines, line[offset:i])
15131513
offset = i
15141514
n = rw
1515-
} else if lastWhitespaceIndex != -1 && lastWhitespaceIndex+1 != i {
1515+
} else if lastWhitespaceIndex != -1 {
15161516
// if there is a space in the line and the line is not breaking at a space/hyphen
15171517
if line[lastWhitespaceIndex].chr == '-' {
15181518
// if break occurs at hyphen, we'll retain the hyphen

view_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,7 @@ func TestLineWrap(t *testing.T) {
230230
line: "hello world",
231231
columns: 6,
232232
expected: []string{
233-
/* EXPECTED:
234233
"hello",
235-
ACTUAL: */
236-
"hello ",
237234
"world",
238235
},
239236
},

0 commit comments

Comments
 (0)