[PR #12764] fix(ui): use oniguruma wasm engine for markdown code highlighting #14359

Open
opened 2026-02-16 18:19:09 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12764

State: open
Merged: No


What does this PR do?

The JS regex engine in @pierre/diffs can cause catastrophic backtracking on certain TextMate grammars (e.g. powershell), freezing the main thread. Switch to a dedicated oniguruma WASM-based highlighter for markdown code blocks. Diff components still use the existing @pierre/diffs highlighter. Add try/catch fallback and regression tests.

How did you verify your code works?

Added 14 unit tests including a regression test with the exact powershell code that triggered the freeze. Verified manually on desktop — the previously frozen session now renders correctly.

WX20260209-091700@2x
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12764 **State:** open **Merged:** No --- ### What does this PR do? The JS regex engine in @pierre/diffs can cause catastrophic backtracking on certain TextMate grammars (e.g. powershell), freezing the main thread. Switch to a dedicated oniguruma WASM-based highlighter for markdown code blocks. Diff components still use the existing @pierre/diffs highlighter. Add try/catch fallback and regression tests. ### How did you verify your code works? Added 14 unit tests including a regression test with the exact powershell code that triggered the freeze. Verified manually on desktop — the previously frozen session now renders correctly. <img width="2960" height="1688" alt="WX20260209-091700@2x" src="https://github.com/user-attachments/assets/5e17f500-f228-4ff4-b7a9-c55a4eb8c221" />
yindo added the pull-request label 2026-02-16 18:19:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14359