story: Highlight the Editor story with tree-sitter on native (#2694)
## Summary The Editor story swapped the built-in tree-sitter highlighter for a `syntect` adapter so WASM builds, which ship without tree-sitter grammars, still get highlighting. Native paid for it, and the story became visibly laggy while typing and scrolling. `syntect` has no incremental mode, so each keystroke: - reparsed the whole document on the main thread, - copied the rope into a `String` twice — once for parsing, once more for the full-document brace scan, because `fold_ranges_for_edit` was not implemented, and every frame `styles()` scanned all document tokens to resolve the visible ones. This limits the `syntect` adapter to `target_family = "wasm"`. Native goes back to the built-in tree-sitter highlighter, which parses incrementally on a background thread behind a 150ms debounce and queries only the visible range. `syntect` moved into the WASM target dependencies, so native never builds it at all. The adapter is also trimmed, since WASM still runs it (both the story copy and the Base showcase copy): - one shared `SyntaxSet` in a `LazyLock`, instead of deserializing the default syntax definitions for every instance - fold ranges computed during `update` and `fold_ranges_for_edit` implemented, removing the extra full-document string copy and brace scan per edit - `resolve_styles` locates the first overlapping highlight by binary search instead of scanning every token on every frame - semantic names cached per `Scope`, instead of `build_string` for every scope of every token No public API changes. ## Test Plan - `cargo check -p gpui-component-story` - `cargo check --target wasm32-unknown-unknown` in `crates/story-web` - `cargo check -p gpui-base --example base_components` - `cargo +nightly check --target wasm32-unknown-unknown` in `crates/base/examples/wasm` - `cargo machete` - `cargo run` and typing in the Editor story ## AI Assistance Diagnosis and the changes in this PR were written with Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
J
Jason Lee committed
c1acb9f3854238da9543af817453726a0efbadb0
Parent: 7edde45
Committed by GitHub <noreply@github.com>
on 8/13/2026, 12:13:23 PM