Skip to content

Commit 02ad690

Browse files
SamVerschuerensindresorhus
authored andcommittedJul 21, 2017
Fix no word wrap bug - fixes #18 (#19)
1 parent e910f82 commit 02ad690

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎index.js

+5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ function exec(str, cols, opts) {
131131
rows.push('');
132132
}
133133

134+
if (rowLength + lengths[i] > cols && options.wordWrap === false) {
135+
wrapWord(rows, word, cols);
136+
continue;
137+
}
138+
134139
rows[rows.length - 1] += word;
135140
}
136141

‎test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ test('no word-wrapping', t => {
8181
const res = fn(fixture3, 15, {wordWrap: false});
8282
t.is(res, '12345678\n901234567890 12\n345');
8383

84-
const res2 = fn(fixture, 5, {wordWrap: false});
85-
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.');
84+
const res2 = fn(fixture3, 5, {wordWrap: false});
85+
t.is(res2, '12345\n678\n90123\n45678\n90 12\n345');
86+
87+
const res3 = fn(fixture, 5, {wordWrap: false});
88+
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.');
8689
});
8790

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

0 commit comments

Comments
 (0)
Please sign in to comment.