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:
can1357
2026-01-29 11:19:33 +01:00
parent 2aa046c053
commit 2ae12a7cee
@@ -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}`;