Skip to content

Commit 632b958

Browse files
committed
Fixing description issues when line breaks present.
1 parent 4868e50 commit 632b958

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

internal/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ func SplitString(input string, lineWidth int) []string {
231231

232232
if currentLine != "" {
233233
result = append(result, currentLine)
234+
currentLine = ""
235+
currentLen = 0
234236
}
235237
}
236238

internal/util/util_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,23 @@ func TestSplitString(t *testing.T) {
272272
`into your very bones.`,
273273
},
274274
},
275+
{
276+
"SplitString long text with line breaks",
277+
args{
278+
"You are now on the lawn.\nYou can smell the freshly cut grass in the " +
279+
"dwindling heat of the autumn afternoon sun.\nYou can see a frisbee flying in the " +
280+
"air, frozen mid-flight in this very sentence. Nearby, a group of picnickers pretends " +
281+
"to study.",
282+
79,
283+
},
284+
[]string{
285+
"You are now on the lawn.",
286+
"You can smell the freshly cut grass in the dwindling heat of the autumn",
287+
"afternoon sun.",
288+
"You can see a frisbee flying in the air, frozen mid-flight in this very",
289+
"sentence. Nearby, a group of picnickers pretends to study.",
290+
},
291+
},
275292
{
276293
"SplitString wide charactors",
277294
args{

0 commit comments

Comments
 (0)