mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 23:20:18 +01:00
cbf03f5b38
## Summary Fixes https://github.com/zed-industries/zed/issues/48684 - Await `parsing_idle()` after `set_language()` in both `Diff::finalized()` and `PendingDiff::finalize()` so that tree-sitter parsing completes before buffer snapshots are taken for excerpts - Without this, the 1ms sync parse timeout almost always expires for non-trivial files, causing excerpts to be created with empty syntax trees and missing syntax highlighting ## Root Cause When the agent panel creates or finalizes a diff, it creates a new `Buffer`, calls `set_language()` (which triggers async tree-sitter parsing), then immediately proceeds to take buffer snapshots and create excerpts **without waiting for parsing to complete**. The sync parse timeout is only 1ms in production (`buffer.rs:1138`), so large files almost always fail the sync parse and fall back to async parsing — but no one awaits the async parse before building the diff. ## Fix Add `buffer.update(cx, |buffer, _| buffer.parsing_idle()).await` after `set_language()` in both code paths (`Diff::finalized()` and `PendingDiff::finalize()`). This is the same pattern already used in `buffer_diff.rs:1728-1731`. ## Test plan - [x] `cargo test -p acp_thread` — all relevant tests pass - [x] `./script/clippy` — no warnings - [x] Manual test: open agent panel, ask it to generate a Python file with multiline strings (`"""`), verify syntax highlighting is correct after diff is finalized Release Notes: - Fixed missing syntax highlighting for multiline strings in agent panel diffs