@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [0.77.0] - 2026-05-28
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -670,7 +670,10 @@ export function wrapTextWithAnsi(text: string, width: number): string[] {
|
|||||||
for (const inputLine of inputLines) {
|
for (const inputLine of inputLines) {
|
||||||
// Prepend active ANSI codes from previous lines (except for first line)
|
// Prepend active ANSI codes from previous lines (except for first line)
|
||||||
const prefix = result.length > 0 ? tracker.getActiveCodes() : "";
|
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
|
// Update tracker with codes from this line for next iteration
|
||||||
updateTrackerFromText(inputLine, tracker);
|
updateTrackerFromText(inputLine, tracker);
|
||||||
}
|
}
|
||||||
@@ -714,7 +717,9 @@ function wrapSingleLine(line: string, width: number): string[] {
|
|||||||
|
|
||||||
// Break long token - breakLongWord handles its own resets
|
// Break long token - breakLongWord handles its own resets
|
||||||
const broken = breakLongWord(token, width, tracker);
|
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];
|
currentLine = broken[broken.length - 1];
|
||||||
currentVisibleLength = visibleWidth(currentLine);
|
currentVisibleLength = visibleWidth(currentLine);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user