Skip to content

editor: Fix hit testing when the editor is clipped#56861

Merged
MrSubidubi merged 2 commits into
zed-industries:mainfrom
timvermeulen:fix-hit-test-clipped-rows
May 15, 2026
Merged

editor: Fix hit testing when the editor is clipped#56861
MrSubidubi merged 2 commits into
zed-industries:mainfrom
timvermeulen:fix-hit-test-clipped-rows

Conversation

@timvermeulen

Copy link
Copy Markdown
Contributor

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:

bug.mov

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • 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

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 15, 2026
@github-actions github-actions Bot added the community champion Issues filed by our amazing community champions! 🫶 label May 15, 2026
@MrSubidubi MrSubidubi self-assigned this May 15, 2026

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! This has bothered me in forever and appreciate this finally being fixed!

@MrSubidubi MrSubidubi added this pull request to the merge queue May 15, 2026
Merged via the queue into zed-industries:main with commit cc40921 May 15, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants