mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
fix(tui): Make markdown.ts more robust to large markdown files (#4463)
This commit is contained in:
committed by
GitHub
Unverified
parent
f2b105dd56
commit
8da1f3d131
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user