zed/crates/editor
Tim Vermeulen cc409210c1
editor: Fix hit testing when the editor is clipped (#56861)
Fixes editor hit testing when the editor is clipped, most easily
noticeable in a partially off-screen markdown block in the agent panel.

`PositionMap::point_for_position` was indexing into `self.line_layouts`
relative to the editor's scroll position (which in this example doesn't
apply because these editors don't scroll), rather than relative to
`self.visible_row_range.start`. This caused the reported column to not
always be computed using the correct row, which especially impacted rows
closer to the bottom of the editor. Notice how closer to the bottom,
`point_for_position` reports the correct row, but reports the column as
0:


https://github.com/user-attachments/assets/2a5b2c8b-2994-4983-a33b-ede209ba00e6




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

Release Notes:

- Fixes selection not always matching the mouse position in a markdown
block in the agent panel
2026-05-15 11:43:39 +00:00
..
benches theme: Split out theme_settings crate (#52569) 2026-03-27 14:41:25 +01:00
src editor: Fix hit testing when the editor is clipped (#56861) 2026-05-15 11:43:39 +00:00
Cargo.toml editor: Add base64 encode/decode commands (#55361) 2026-05-05 04:36:18 +00:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00