fix(tui): Make markdown.ts more robust to large markdown files (#4463)
This commit is contained in:
@@ -145,7 +145,9 @@ export class Markdown implements Component {
|
|||||||
const token = tokens[i];
|
const token = tokens[i];
|
||||||
const nextToken = tokens[i + 1];
|
const nextToken = tokens[i + 1];
|
||||||
const tokenLines = this.renderToken(token, contentWidth, nextToken?.type);
|
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)
|
// Wrap lines (NO padding, NO background yet)
|
||||||
@@ -154,7 +156,9 @@ export class Markdown implements Component {
|
|||||||
if (isImageLine(line)) {
|
if (isImageLine(line)) {
|
||||||
wrappedLines.push(line);
|
wrappedLines.push(line);
|
||||||
} else {
|
} 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
|
// Combine top padding, content, and bottom padding
|
||||||
const result = [...emptyLines, ...contentLines, ...emptyLines];
|
const result = emptyLines.concat(contentLines, emptyLines);
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
this.cachedText = this.text;
|
this.cachedText = this.text;
|
||||||
|
|||||||
Reference in New Issue
Block a user