# editor: Fix hit testing when the editor is clipped \(\#56861\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cc409210c151716aed980b67b4f186768a2599f3)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cc409210c151716aed980b67b4f186768a2599f3

Requested commit: cc409210c151716aed980b67b4f186768a2599f3

Commit: cc409210c151716aed980b67b4f186768a2599f3

Tree: e9edfac5116e42f6ff6cc7d195b42233fe413e72

Author: Tim Vermeulen

Committer: GitHub

## Message

```
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
```

## Parents

- [dca5976f82a6816f126cbab2cb16568a7c173fcf](https://git.cafe/gitcafe/zed/commit/dca5976f82a6816f126cbab2cb16568a7c173fcf?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cc409210c151716aed980b67b4f186768a2599f3?format=markdown)
