markdown: Fix text selection position in centered/right-aligned markdown table cells (#57283)

Table header cells are always center-aligned. When selecting text in
them, the selection highlight was drawn at the left edge of the cell
instead of over the actual visible text. Clicking on a character also
mapped to the wrong source index.

The bug was that `bounds_for_source_range` and
`source_index_for_position` used raw layout x-coordinates (which start
at 0), without accounting for the horizontal offset GPUI applies when
rendering center- or right-aligned text.

The fix stores the `TextAlign` on each `RenderedLine` at flush time,
then uses it to compute an alignment offset per wrapped row segment.
That offset is:
- subtracted from the click position before resolving it to a source
index
- added to the x-coordinates when computing selection highlight bounds

**Before**:


https://github.com/user-attachments/assets/49fd7748-eb1b-4199-bc2f-23cddcb528c5

**After**:


https://github.com/user-attachments/assets/93657652-d548-4e5a-b011-be29bb0a3d9e


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)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Markdown: Fixed text selection highlight appearing at the wrong
position when selecting text in markdown table headers.
735980b158Remco Smits committed on 6/1/2026, 6:54:27 AM· committed by GitHubparent954ee58
1 file changedLine totals unavailable