fix(tui): split multi-line strings in renderOutputBlock to prevent width overflow
Multi-line bash commands (e.g., for loops with newlines) were being passed as single "lines" to renderOutputBlock. Since visibleWidth() treats newlines as width 0, truncateToWidth() calculated incorrect truncation points. The result was rendered lines with embedded newlines that exceeded terminal width, causing "Rendered line N exceeds terminal width" crashes. Split section lines by newlines before processing so each line gets properly truncated and wrapped with box borders.
This commit is contained in:
@@ -67,7 +67,8 @@ export function renderOutputBlock(options: OutputBlockOptions, theme: Theme): st
|
||||
padToWidth(buildBarLine(theme.boxSharp.teeRight, theme.boxSharp.teeLeft, section.label), lineWidth, bgFn),
|
||||
);
|
||||
}
|
||||
for (const line of section.lines) {
|
||||
const allLines = section.lines.flatMap(l => l.split("\n"));
|
||||
for (const line of allLines) {
|
||||
const text = truncateToWidth(line, contentWidth, theme.format.ellipsis);
|
||||
const innerPadding = " ".repeat(Math.max(0, contentWidth - visibleWidth(text)));
|
||||
const fullLine = `${contentPrefix}${text}${innerPadding}${contentSuffix}`;
|
||||
|
||||
Reference in New Issue
Block a user