Repository navigation
Editor: Nim and Typst on the shared TextMate layer, so a long line can't freeze the window - #26987
Conversation
…-line limits The editor's Nim and Typst highlighting moves from vscode-textmate onto the Shiki core + Oniguruma layer chat uses, with the same per-line length cap and time limit. A skipped line leaves the rest of the file plain instead of freezing the window. Chat code block labels now name catalogue languages (vue -> Vue, ts -> TypeScript).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (16)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughNative chat code blocks now display language labels resolved from bundled language metadata, while preserving unrecognized tags. The syntax highlighter and Monaco language providers now use a shared TextMate core and bounded line-tokenization helper. Nim and Typst grammar loaders return language registrations without scope arguments. Provider tests cover long-line fallback and tokenization state. Priority: ⬆️ High Estimated code review effort: Merge Risk: ⚪ Minimal · up to The shared-core grammar concern does not block merging, and no other actionable issue remains from this review. Pre-merge checks |
|
ELI5
Opening a Nim or Typst file with one very long line (for example a generated file that embeds a big hex string) could freeze the whole Orca window for seconds, or for minutes on bigger files. Now such a line simply isn't coloured, and the window stays responsive. Normal Nim and Typst files look exactly as before.
What Changed
The problem. The code editor colours Nim and Typst with a separate TextMate engine (Microsoft's
vscode-textmate). It tokenized every line with no time limit and no length cap. The editor's own line-length cap only applies to its built-in grammars, not to custom tokenizers like this one. Some long lines take time that grows with the square of their length, and one regex scan over such a line can't be interrupted.Measured on main with the shipped grammars: a 46 KB one-line Nim file holding a hex string in
"""…"""took 12.6 s to tokenize in Node. In the running app it froze the renderer for 8.1 s (one blocked task). A 50 KB line of dense Typst code took 36 s, and an 80 KB unbroken identifier in Nim took 49 s.Orca also shipped two TextMate engines: that one for the editor, and Shiki's fork for native chat (#26343).
What you see now.
```tsshows "TypeScript",```vueshows "Vue",```powershellshows "PowerShell". Before, these showed the raw tag ("ts", "vue", "powershell") while```pythonalready showed "Python". Tags the catalogue doesn't know still show as written.How it works.
src/renderer/src/lib/syntax-highlighting/): Shiki core on Orca's one Oniguruma WASM. A newtextmate-core.tsowns the regex-engine adapter and the per-line limits, and chat and the editor both call it.registerTokensProviderFactoryadapter is kept. State equality stays structural (rule-stackequals), so after an edit the editor stops re-tokenizing as soon as states converge. There's a test for that.vs/vs-dark, mapped by each token's last scope as before. Adding Dark+/Light+ TextMate rules to the editor themes is a later step.vscode-textmateis removed frompackage.jsonand the lockfile.vscode-onigurumastays as the shared engine.Why
@shikijs/monaco. It monkey-patches Monaco globally, loads every grammar up front, and compares states by identity, so every edit re-tokenizes to the end of the file.Linked Issue
Follows #26343 (no separate issue).
Visual Proof
Hidden dev app on macOS (dark theme,
vs-darkeditor), fresh isolated profiles, before = main2cb2bef67e3, after = this branch. Steps were driven by a separate non-Claude QA agent over the DevTools protocol. Chat used a local stand-in agent, not a real agent.sample.nimin the editor (byte-identical)sample.typin the editor (byte-identical)generated_logo.nim```vueblock labelAll chat labels in the same reply, before → after:
ts→ TypeScript,python→ Python (same),bash→ Bash (same),vue→ Vue,powershell→ PowerShell,zzlang→ zzlang (unknown, same).Testing
ts,py,yml,vue,tsxandps1tags.monaco-languages,syntax-highlighting, native-chat and editor component suites, andorca-ci-checks(22/22) pass.Review
Agent skill upstream boundary
Notes
Security: no new inputs or channels. Performance: worst case per editor line is now bounded; normal files unchanged. Backwards compatibility: no persisted data or settings touched.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)