Closed vadimdemedes closed 5 years ago
I asked the author of https://github.com/chalk/wrap-ansi/pull/30 to copy tests from this PR, so that I can close this one, since the other one fixes many issues at once and has way less code.
@vadimdemedes Can this be closed now?
Oh yes, sorry, forgot!
Fixes https://github.com/chalk/wrap-ansi/issues/27.
The original issue is about
wrap-ansi
stripping the beginning space, if string is wrapped into an ansi escape (usually colors). I think it's ok forchalk.green(' hello ')
, because spaces won't be colorized anyway. However, forchalk.bgGreen(' hello ')
this results in:Reason it was happening is because
wrap-ansi
splits input string by space here https://github.com/chalk/wrap-ansi/blob/master/index.js#L82.This PR fixes this case by scanning result of
split()
and joining opening escape, content and closing escape (following is pseudo code).This PR is still failing, because it doesn't yet handle
chalk.bgGreen(' hello ' + chalk.red('world'))
case. Any help is appreciated!