File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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.\n You can smell the freshly cut grass in the " +
279+ "dwindling heat of the autumn afternoon sun.\n You 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 {
You can’t perform that action at this time.
0 commit comments