mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
**Problem.** A line of many `>` characters makes `marked` produce one nested blockquote token per `>`. The blockquote branch of `Markdown.renderToken` renders its children at `Math.max(1, width - 2)` columns, then wraps each child line again at that width and adds a `│ ` prefix. Once the nesting uses up the width (about 39 levels at 80 columns), the width stays clamped at 1. From then on, each child line (`│ x`, 3 columns wide) is wrapped into about 3 lines at every further level, so the output roughly triples per level. At 80 columns: - 50 levels: 4096 lines, about 30 s to render; - 55 levels: `push(...lines)` exceeds the JavaScript argument limit and throws `RangeError: Maximum call stack size exceeded`, which crashes pi. Reopening the session crashes it again. **Fix.** - When there is no room left for another border (`width < 3`), the blockquote branch now renders its child tokens at the same width without adding a border and without wrapping them again. - Child lines are appended with a loop instead of a spread `push`. Quotes that fit in the width render exactly as before. **Testing.** - Added a regression test in `packages/tui/test/markdown.test.ts`: 60 nested `>` rendered at width 80 give one line that keeps the content. Without the fix the test fails with the RangeError; with it, all 92 tests in that file pass (`node --test test/markdown.test.ts`). - `npm run check` passes. - Reproduction script rendering `">".repeat(n) + "x"` at width 80: - before: 50 levels gave 4096 lines in 29.5 s, and 55 or 60 levels threw a RangeError; - after: 40, 50, 60 and 200 levels each give 1 line in about 10 ms. **Not covered.** A run of about 2000 `>` still overflows the stack inside `marked`'s own lexer, before pi's renderer runs. That is a separate limit and is not changed here. Fixes #11272 Requested by @davidbrai Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| alt-screen-large-transcript-bench.ts | ||
| autocomplete-skill-slash.test.ts | ||
| autocomplete.test.ts | ||
| bug-regression-isimageline-startswith-bug.test.ts | ||
| chat-simple.ts | ||
| colors.test.ts | ||
| editor-history-keybindings.test.ts | ||
| editor.test.ts | ||
| exit-restore.test.ts | ||
| fuzzy.test.ts | ||
| image-test.ts | ||
| input.test.ts | ||
| key-tester.ts | ||
| keybindings.test.ts | ||
| keys.test.ts | ||
| latex.test.ts | ||
| layout.test.ts | ||
| markdown.test.ts | ||
| mouse-components.test.ts | ||
| native-clipboard-linux.test.ts | ||
| native-module-path.test.ts | ||
| native-platform.test.ts | ||
| overlay-non-capturing.test.ts | ||
| overlay-options.test.ts | ||
| overlay-short-content.test.ts | ||
| program-status.test.ts | ||
| regression-overlay-cjk-boundary.test.ts | ||
| regression-regional-indicator-width.test.ts | ||
| regression-sigwinch-kill-eacces.test.ts | ||
| regression-slice-by-column-ansi-order.test.ts | ||
| render-churn-bench.ts | ||
| select-list.test.ts | ||
| settings-list.test.ts | ||
| stdin-buffer.test.ts | ||
| tab-width.test.ts | ||
| terminal-colors.test.ts | ||
| terminal-image.test.ts | ||
| terminal.test.ts | ||
| test-themes.ts | ||
| truncate-to-width.test.ts | ||
| truncated-text.test.ts | ||
| tui-alt-screen.test.ts | ||
| tui-cell-size-input.test.ts | ||
| tui-overlay-style-leak.test.ts | ||
| tui-render.test.ts | ||
| tui-shrink.test.ts | ||
| viewport-overwrite-repro.ts | ||
| virtual-terminal.ts | ||
| visible-width.test.ts | ||
| wheel-scroll.test.ts | ||
| word-navigation.test.ts | ||
| wrap-ansi.test.ts | ||