zed/crates/markdown
Julian Bruyers 7230a5acc5
Fix markdown preview partially unclickable links on linewraps in tables (#65366)
## Summary

Closes #65147

Fixes partially unclickable rows of wrapped links in Markdown tables,
affecting Markdown previews and rendered agent responses. A detailed
video of the bug, provided by issue author
[@machadinhos](https://github.com/machadinhos), can be found
[here](https://github-production-user-asset-6210df.s3.amazonaws.com/101654160/665208322-97183453-77c1-4364-94cf-d6f7eae85810.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20261008%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20261008T220525Z&X-Amz-Expires=300&X-Amz-Signature=c92d295ab82d512815bd9d4dc011293c3c8a2b34134781823d835d757a633f11&X-Amz-SignedHeaders=host&response-content-type=video%2Fmp4).

Currently vertically centered table cells can cause hit testing to
mistake a position inside a later cell for a gap between text blocks.
Defer the first gap fallback until all text blocks have been checked,
allowing actual text hits to take precedence.

## Testing

Implemented `#[gpui::test]'s` for different table layouts and link
lengths

- 6f8a223669d9b8eb6c8c810c3467dbe8dea72230
- 87e2e59176f3258eb8c200749823ee68af87167e
- b6456a474c5daa871ad57c08894140f157296490
- 15b581003241be0b2868a663ad56a274569cc7a3

The fix passes all 188/188 tests for the markdown crate, the previous
implementation fails all newly added test cases.

```text
test tests::test_wrapped_table_links_hit_testing ... ok
test tests::test_wrapped_table_link_mouse_release ... ok
test tests::test_wrapped_table_link_unicode_and_surrounding_text ... ok
test tests::test_wrapped_table_link_column_positions_and_alignment ... ok
test tests::test_wrapped_table_link_hover_click_and_resize ... ok
test tests::test_copy_button_copies_commonmark_code_block_content ... ok
test tests::test_wrapped_table_link_interactions_in_all_columns ... ok

test result: ok. 188 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.89s
```

Build passed on **macOS** and **Windows**

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed wrapped links in Markdown tables being partially unclickable in
Markdown previews and agent responses

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
2026-10-09 08:27:23 +00:00
..
examples theme: Split out theme_settings crate (#52569) 2026-03-27 14:41:25 +01:00
src Fix markdown preview partially unclickable links on linewraps in tables (#65366) 2026-10-09 08:27:23 +00:00
Cargo.toml Reduce the dependency footprint (#65176) 2026-10-05 12:44:26 +00:00
LICENSE-GPL