Skip to content

Commit d3fe652

Browse files
committed
fix text wrapping issues
1 parent 6d6603b commit d3fe652

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/render/src/shared/utils/pretty.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,15 @@ export const wrapText = (
185185
return `${linePrefix}${text}`;
186186
}
187187
let wrappedText = linePrefix + text;
188-
let currentLineStartIndex = 0;
188+
let currentLineStartIndex = linePrefix.length;
189189
while (wrappedText.length - currentLineStartIndex > maxLineLength) {
190190
const overflowingCharacterIndex = Math.min(
191191
currentLineStartIndex + maxLineLength - 1,
192192
wrappedText.length,
193193
);
194+
if (!wrappedText.includes(' ', currentLineStartIndex)) {
195+
return wrappedText;
196+
}
194197
for (let i = overflowingCharacterIndex; i >= currentLineStartIndex; i--) {
195198
const char = wrappedText[i];
196199
if (char === ' ') {

0 commit comments

Comments
 (0)