chalk / wrap-ansi

Wordwrap a string with ANSI escape codes
MIT License
120 stars 25 forks source link

Newline handling in 6.0.0 #39

Closed unindented closed 4 years ago

unindented commented 5 years ago

In wrap-ansi@5.0.0 all newlines are converted properly:

const wrapAnsi = require("wrap-ansi@5.0.0")
console.log(wrapAnsi('a\r\n\r\nb', 5)) // outputs "a\n\nb"

In wrap-ansi@6.0.0 not all newlines are converted:

const wrapAnsi = require("wrap-ansi@6.0.0")
console.log(wrapAnsi('a\r\n\r\nb', 5)) // outputs "a\r\n\nb"
kevva commented 5 years ago

In 5.1.0 I get the same result as in 6.0.0. I think the change happened in https://github.com/chalk/wrap-ansi/pull/33 which was merged after 5.0.0. I don't think we should "normalize" the newlines but rather keep them as they were inputted.

unindented commented 5 years ago

Fair enough. So I guess this is a "Won't fix"?

kevva commented 5 years ago

It needs to be addressed in some way. Currently the output it neither untouched or completely normalized. We just need to decide on how we want it to work. I'll let others chime in before submitting a PR.

sindresorhus commented 5 years ago

I think it's totally fine for us to normalize newlines as long as we document the behavior. It's the wanted behavior in most cases.