chalk / slice-ansi

Slice a string with ANSI escape codes
MIT License
47 stars 21 forks source link

Adds moot escape codes #6

Closed sindresorhus closed 7 years ago

sindresorhus commented 8 years ago
sliceAnsi('\u001b[31municorn\u001b[39m', 0, 3);
//=> '\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31muni\u001b[39m'

Notice how it prepends a lot of moot \u001b[31m to the output.

I added a failing skipped test: https://github.com/chalk/slice-ansi/commit/f725d7677cb8b734f63b39fbbabd7261fe3be821

// @dthree

kevva commented 7 years ago

I guess these are false positives too then https://github.com/chalk/slice-ansi/blob/master/test.js#L28-L30?

I think we need to make sure we're not inside a escape here https://github.com/chalk/slice-ansi/blob/master/index.js#L66 before wrapping.