Skip to content

Commit 647564a

Browse files
authored
fix: breakLines regression versus paginated content (#1108)
[This PR](#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.
1 parent 9baee32 commit 647564a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/core/lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ const wrapAnsi = require('wrap-ansi');
1010
exports.breakLines = (content, width) =>
1111
content
1212
.split('\n')
13-
.map((line) => wrapAnsi(line, width, { trim: false, hard: true }))
13+
.map((line) => wrapAnsi(line, width, { trim: false, hard: true }).split('\n'))
1414
.join('\n');

packages/inquirer/lib/utils/screen-manager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class ScreenManager {
160160
// re: trim: false; by default, `wrap-ansi` trims whitespace, which
161161
// is not what we want.
162162
// re: hard: true; by default', `wrap-ansi` does soft wrapping
163-
return lines.map((line) => wrapAnsi(line, width, { trim: false, hard: true }));
163+
return lines.map((line) =>
164+
wrapAnsi(line, width, { trim: false, hard: true }).split('\n')
165+
);
164166
}
165167

166168
/**

0 commit comments

Comments
 (0)