fix(tui): Make markdown.ts more robust to large markdown files (#4463)

This commit is contained in:
Nelson Herrera
2026-05-13 01:31:09 -07:00
committed by GitHub
Unverified
parent f2b105dd56
commit 8da1f3d131
+7 -3
View File
@@ -145,7 +145,9 @@ export class Markdown implements Component {
const token = tokens[i];
const nextToken = tokens[i + 1];
const tokenLines = this.renderToken(token, contentWidth, nextToken?.type);
renderedLines.push(...tokenLines);
for (const tokenLine of tokenLines) {
renderedLines.push(tokenLine);
}
}
// Wrap lines (NO padding, NO background yet)
@@ -154,7 +156,9 @@ export class Markdown implements Component {
if (isImageLine(line)) {
wrappedLines.push(line);
} else {
wrappedLines.push(...wrapTextWithAnsi(line, contentWidth));
for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {
wrappedLines.push(wrappedLine);
}
}
}
@@ -191,7 +195,7 @@ export class Markdown implements Component {
}
// Combine top padding, content, and bottom padding
const result = [...emptyLines, ...contentLines, ...emptyLines];
const result = emptyLines.concat(contentLines, emptyLines);
// Update cache
this.cachedText = this.text;