mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Fixes an autoscroll bug that sometimes obscures the current row behind a sticky header. The bug was caused by `Editor::autoscroll_vertically` using the `sticky_header_line_count` value that was cached during the previous render, which isn't necessarily the number of sticky headers that the scroll target needs, e.g. - when jumping to a definition - when pressing the up arrow key when the selection is in the topmost visible row with `"vertical_scroll_margin": 0` This fixes that by not caching `sticky_header_line_count` and instead querying Tree-sitter on the fly to get the number of sticky headers that the scroll target needs. Performance-wise this seem okay, I measured it to take less than 200µs on my machine using a very large Rust file (and there are still some possible ways to optimize this if necessary). In particular, the pathological huge single-line file case as discussed in #48450 shouldn't be an issue here because unlike the main sticky header Tree-sitter query, here we query the outline items that contain a particular point rather than those that intersect an entire row. The `ScrollCursorTop` handler is also simplified to use the same shared function for counting the number of sticky headers, since that action doesn't rely on autoscroll. Before: https://github.com/user-attachments/assets/efb12776-82d9-4b94-baa5-347ec769fb98 After: https://github.com/user-attachments/assets/236deb9f-fe06-43bd-b167-7bd3ab719e4c Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #50803 Release Notes: - Fixed sticky headers sometimes obscuring the current row. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> |
||
|---|---|---|
| .. | ||
| benches | ||
| src | ||
| build.rs | ||
| Cargo.toml | ||
| LICENSE-GPL | ||