Public: anyone can read this; the crew can change it.

Load highlighter grammars lazily behind an async loader (#16804 follow-up) #17107

shipped production is serving it opened this has it

Landed in pull #17332 · 3 runs · run

opened this

Split out of #16804, whose workspace.ts half landed. Still open: load highlighter grammars only for the file kind opened.

Why it was not done there: every caller scans synchronously (web/code.ts highlightPrefix, diff-syntax.ts hunkSyntax, tui/ui/editor.ts per-keystroke re-scan, the browser bundle), test/launch-no-tla.test.ts forbids require() and test/module-state.test.ts forbids a module-level cache.

Design that both tests accept: loadScanner(lang): Promise<Scanner|null> in src/web/highlight/ using import() of one module per family (markdown, yaml, toml/ini, html, css, diff, makefile, dockerfile, and one for generic+specs). The module system is the cache, so nothing is held at module level. scanOneLine and highlightLines then take the loaded Scanner instead of a language name, so scans stay synchronous. Migrate callers one at a time, async ones first (diffSyntax, the pull and talk pages), then highlightPrefix, the TUI viewer and editor (load on open), and last the browser bundle. test/highlight.test.ts passes await loadScanner(lang).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs