mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-24 17:40:47 +01:00
532532bb80
# Objective Fix the filtering of inlay hints around the buffer bounds. The per-chunk range filter compared anchors, and anchor order includes the bias. A parameter hint (`anchor_before`) clamped to the end of the buffer sorted before the chunk's end anchor and was kept, while a type/other hint (`anchor_after`) exactly at the end of a file without a trailing newline compared equal to it and was dropped. Also remove the redundant `anyhow::Result` and `async` from the LSP-to-project inlay hint conversion. ## Solution - Drop LSP inlay hints whose line is past the last buffer row before converting them. Positions past a line's end are still clipped to the line end, as the LSP spec prescribes for `Position.character`. - Compare offsets instead of anchors in the per-chunk range filter, so it does not depend on the hint's anchor bias, and treat the range end as inclusive when it is the end of the buffer. - Make `lsp_to_project_hint` a pure function over a `BufferSnapshot`. The resolve path now converts the response against the same snapshot the request position was produced from. ## Testing - `test_inlay_hints_at_buffer_bounds`: row overflow for both hint kinds, column overflow clipping on a non-last row, and a type hint exactly at the buffer end. Fails on `main` on the row overflow and the buffer end cases. - An out-of-bounds parameter hint added to the collab `test_inlay_hint_refresh_is_forwarded`. - Manually verified that rust-analyzer's closing brace hint appears after the final `}` of a file without a trailing newline. ## 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 adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed inlay hints positioned past the end of the buffer being shown on its last line, and inlay hints exactly at the end of a file without a trailing newline being hidden. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>