markdown: Make highlighting of rendered markdown more accurate (#54744)

Paints selections and search highlights of rendered markdown more
accurately, to properly match what's actually being selected.

Particularly noticeable when the selection spans multiple rows in a
table cell or when it starts right after a soft wrap.

|Before|After|
| --- | --- |
|<img width="831" height="677" alt="before"
src="https://github.com/user-attachments/assets/3b2c33be-e4cb-400f-9ba6-4163eb438f99"
/> | <img width="831" height="677" alt="after"
src="https://github.com/user-attachments/assets/04161dd8-7f4a-46c5-8c63-3497d3533f6d"
/> |


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:

- Fixed selection and search highlights in rendered markdown not always
being displayed accurately.
2595391217Tim Vermeulen committed on 4/24/2026, 12:51:52 PM· committed by GitHubparent7780533
1 file changedLine totals unavailable