Skip to content

Commit

Permalink
Merge 47239c1 into 8640dc3
Browse files Browse the repository at this point in the history
  • Loading branch information
stroncium committed Feb 27, 2019
2 parents 8640dc3 + 47239c1 commit fd394ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const exec = (string, columns, options = {}) => {
rows[rows.length - 1] = options.trim === false ? rows[rows.length - 1] : rows[rows.length - 1].trim();
let rowLength = stringWidth(rows[rows.length - 1]);

if (rowLength || word === '') {
if (index !== 0) {
if (rowLength === columns && options.wordWrap === false) {
// If we start with a new word but the current row length equals the length of the columns, add a new row
rows.push('');
Expand Down
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ test('supports unicode surrogate pairs', t => {
t.is(m('a\uD83C\uDE00bc', 2, {hard: true}), 'a\n\uD83C\uDE00\nbc');
t.is(m('a\uD83C\uDE00bc\uD83C\uDE00d\uD83C\uDE00', 2, {hard: true}), 'a\n\uD83C\uDE00\nbc\n\uD83C\uDE00\nd\n\uD83C\uDE00');
});

test('#26, does not multiplicate leading spaces with no trimming', t => {
t.is(m(' a ', 10, {trim: false}), ' a ');
t.is(m(' a ', 10, {trim: false}), ' a ');
});

test('#27, does not remove leading space when line starts with ansi escape and no trimming', t => {
t.is(m(chalk.bgGreen(` ${chalk.black('OK')} `), 100, {trim: false}), chalk.bgGreen(` ${chalk.black('OK')} `));
t.is(m(chalk.bgGreen(` ${chalk.black('OK')} `), 100, {trim: false}), chalk.bgGreen(` ${chalk.black('OK')} `));
});

0 comments on commit fd394ac

Please sign in to comment.