chalk / wrap-ansi

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

Off by one if trimming is disabled #25

Closed watson closed 5 years ago

watson commented 6 years ago

Issuehunt badges

If trimming is disabled, and you're wrapping a text a say length 3, and there's a whitespace right where the wrap should occur, the whitespace remains and the line break is appended to it. This results in the line being one char too long:

console.log(JSON.stringify(trim('foo bar', 3)))                // => "foo\nbar"
console.log(JSON.stringify(trim('foo bar', 3, {trim: false}))) // => "foo \nbar"

stroncium earned $40.00 by resolving this issue!

IssueHuntBot commented 5 years ago

@issuehunt has funded $40.00 to this issue. See it on IssueHunt

IssueHuntBot commented 5 years ago

@sindresorhus has rewarded $36.00 to @stroncium. See it on IssueHunt