Skip to content

Commit

Permalink
fix: breakLines regression versus paginated content
Browse files Browse the repository at this point in the history
[This PR](SBoudrias#1106) updated `breakLines` to use `wrap-ansi`. However, in doing so, we broke the paginator. It assumes that the return value will be of the same length as the original array, but that broken lines will be subarrays.
  • Loading branch information
starpit committed Apr 27, 2022
1 parent 9baee32 commit 982024d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/lib/utils.js
Expand Up @@ -10,5 +10,5 @@ const wrapAnsi = require('wrap-ansi');
exports.breakLines = (content, width) =>
content
.split('\n')
.map((line) => wrapAnsi(line, width, { trim: false, hard: true }))
.map((line) => wrapAnsi(line, width, { trim: false, hard: true }).split('\n'))
.join('\n');
4 changes: 3 additions & 1 deletion packages/inquirer/lib/utils/screen-manager.js
Expand Up @@ -160,7 +160,9 @@ class ScreenManager {
// re: trim: false; by default, `wrap-ansi` trims whitespace, which
// is not what we want.
// re: hard: true; by default', `wrap-ansi` does soft wrapping
return lines.map((line) => wrapAnsi(line, width, { trim: false, hard: true }));
return lines.map((line) =>
wrapAnsi(line, width, { trim: false, hard: true }).split('\n')
);
}

/**
Expand Down

0 comments on commit 982024d

Please sign in to comment.