@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed ANSI text wrapping to avoid stack overflows on very long wrapped lines ([#5185](https://github.com/earendil-works/pi/issues/5185)).
|
||||
|
||||
## [0.77.0] - 2026-05-28
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -670,7 +670,10 @@ export function wrapTextWithAnsi(text: string, width: number): string[] {
|
||||
for (const inputLine of inputLines) {
|
||||
// Prepend active ANSI codes from previous lines (except for first line)
|
||||
const prefix = result.length > 0 ? tracker.getActiveCodes() : "";
|
||||
result.push(...wrapSingleLine(prefix + inputLine, width));
|
||||
const wrappedLines = wrapSingleLine(prefix + inputLine, width);
|
||||
for (const wrappedLine of wrappedLines) {
|
||||
result.push(wrappedLine);
|
||||
}
|
||||
// Update tracker with codes from this line for next iteration
|
||||
updateTrackerFromText(inputLine, tracker);
|
||||
}
|
||||
@@ -714,7 +717,9 @@ function wrapSingleLine(line: string, width: number): string[] {
|
||||
|
||||
// Break long token - breakLongWord handles its own resets
|
||||
const broken = breakLongWord(token, width, tracker);
|
||||
wrapped.push(...broken.slice(0, -1));
|
||||
for (let i = 0; i < broken.length - 1; i++) {
|
||||
wrapped.push(broken[i]!);
|
||||
}
|
||||
currentLine = broken[broken.length - 1];
|
||||
currentVisibleLength = visibleWidth(currentLine);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user