Closed kjirou closed 6 years ago
I understood the meaning of using ansi-styles
.
It was a bad fix, so I close it.
The failing tests are still useful, even if the fix is not correct. Can you remove the fix and keep the tests only? (Note: No need to open a new PR each time. You can just update this one)
@sindresorhus I rebased to be test only.
I rewrote to add minimum tests to reproduce the contents of #14 .
Contents of an old description
Hello. Fix to work correctly when ordinary string and ANSI string are mixed. In order to fix bugs, I fixed the places that I seemed wrong with internal logic. Although the correction range has become wide, can you confirm it? Especially I did not know the situation that needed `ansi-styles`. Ref) #14 ### Problem summary reproduce.js) ```js const sliceAnsi = require('./index'); const chalk = require('chalk'); const str = 'a' + chalk.red('bc') + 'd'; console.log('a:', sliceAnsi(str, 0, 1) === 'a'); console.log('b:', sliceAnsi(str, 1, 2) === chalk.red('b')); console.log('c:', sliceAnsi(str, 2, 3) === chalk.red('c')); console.log('d:', sliceAnsi(str, 3, 4) === 'd'); ``` before) ```bash node reproduce.js a: false b: true c: false d: false ``` after) ```bash node reproduce.js a: true b: true c: true d: true ```