Skip to content

Commit

Permalink
Fix no word wrap bug - fixes #18 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren authored and sindresorhus committed Jul 21, 2017
1 parent e910f82 commit 02ad690
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ function exec(str, cols, opts) {
rows.push('');
}

if (rowLength + lengths[i] > cols && options.wordWrap === false) {
wrapWord(rows, word, cols);
continue;
}

rows[rows.length - 1] += word;
}

Expand Down
7 changes: 5 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ test('no word-wrapping', t => {
const res = fn(fixture3, 15, {wordWrap: false});
t.is(res, '12345678\n901234567890 12\n345');

const res2 = fn(fixture, 5, {wordWrap: false});
t.is(res2, 'The q\nuick\nbrown\nfox j\numped\nover\nthe l\nazy d\nog an\nd the\nn ran\naway\nwith\nthe u\nnicor\nn.');
const res2 = fn(fixture3, 5, {wordWrap: false});
t.is(res2, '12345\n678\n90123\n45678\n90 12\n345');

const res3 = fn(fixture, 5, {wordWrap: false});
t.is(res3, 'The q\nuick\nbrown\nfox j\numped\nover\nthe l\nazy d\nog an\nd the\nn ran\naway\nwith\nthe u\nnicor\nn.');
});

// https://github.com/chalk/wrap-ansi/issues/10
Expand Down

0 comments on commit 02ad690

Please sign in to comment.