word-wrap icon indicating copy to clipboard operation
word-wrap copied to clipboard

Not inserting additional newlines when there is leading whitespace in a multiline string.

Open korexus opened this issue 1 year ago • 0 comments

Fixes https://github.com/jonschlinkert/word-wrap/issues/27

When cut is false and the text to wrap contains newlines, the split slurps up whitespace following those newlines. This was stopping the newline character being removed (as it was not at the end of the string) and caused an additional newline to be added.

Also, the whitespace that should have been at the start of the next line had no effect, as it ended up on the additional line that was created.

Checking for trailing whitespace following a newline, moving it to the start of the next line, and removing the newline character fixes the test case mentioned on the issue.

korexus avatar Nov 20 '24 23:11 korexus