mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-20 15:40:29 +01:00
56a157e5b0
## Summary `BufferChunks::seek` rebuilds the diagnostic endpoints and zeroes the severity depths, but it left `unnecessary_depth` alone. After a seek from inside an unnecessary-code diagnostic, every later chunk reported `is_unnecessary`. `initialize_diagnostic_endpoints` now zeroes it with the other depths. `FoldChunks` seeks when it skips a fold, so text after a fold that starts in unused code could render faded. That symptom is inferred from the code; only the iterator is tested. `seek` also called `initialize_diagnostic_endpoints` twice when the iterator used cached highlights. The first call is removed. A standalone release binary linked against `language` timed `seek` on an iterator with cached highlights. The buffer is 4,000 lines of Rust with a diagnostic on each of the first 2,000 lines. Each seek stays inside the iterator's current range so highlights are not re-fetched. Median time per seek: | Diagnostics in seek range | Before | After | |---|---|---| | 0 | 210 ns | 114 ns | | 1 | 0.77 µs | 0.40 µs | | 10 | 1.28 µs | 0.68 µs | | 100 | 6.7 µs | 3.4 µs | | 1,000 | 59 µs | 29 µs | ## Testing `cargo test -p language -- chunk diagnostic` passes. `test_chunks_seek_out_of_unnecessary_diagnostic` is new and fails without the fix. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed unused-code fading sometimes extending past the unused code