markdown: Respect buffer_line_height in code blocks (#62785)

# Objective

- Fixes #62528
- Code blocks in rendered markdown ignored the `buffer_line_height`
setting. With the line height left unset, they fell back to the ambient
default of ~1.618, so the same code was spaced more loosely in markdown
than it was in an editor or the terminal.
- The extra leading is most obvious with box-drawing characters — the
ASCII-art box from the issue renders as disconnected stripes instead of
continuous vertical rules.
- The issue also notes that the preview font "seems bigger". That part
is working as intended and is not changed here: preview code blocks size
from `markdown_preview_font_size`, which falls back to `ui_font_size`
rather than `buffer_font_size` so that temporary UI zoom doesn't resize
the preview. Users who want it to match the editor can set
`markdown_preview_font_size` explicitly.

## Solution

- Set `line_height` on the code block text style in
`MarkdownStyle::themed_with_overrides`, derived from
`theme_settings.buffer_line_height`.
- The value is `relative(...)` rather than absolute pixels so it tracks
the code font size, which some callers override after building the style
(e.g. the agent panel sets `code_block.text.font_size` downstream). An
absolute value computed from the theme's font size would be wrong for
those callers.
- Scope: this applies to every `MarkdownFont` variant — preview, agent
panel, and editor — since the code block style is shared and
`with_preview_overrides` doesn't touch line height.
- Prose leading is deliberately unchanged. It stays a per-element
typographic choice, independent of the buffer setting.

## Testing

- `cargo test -p markdown` — 145 passed, 0 failed.
- Added
`test_code_block_line_height_follows_buffer_line_height_setting`:
renders a paragraph plus a fenced code block at `buffer_line_height` 1.2
and 1.8, asserts the code block's rendered line height tracks the
setting, and asserts prose leading does *not* move.
- Added `test_code_block_line_height_tracks_overridden_code_font_size`:
overrides `code_block.text.font_size` after building the style and
asserts the line height follows the override. This is what pins the
`relative` vs. absolute choice.
- To reproduce manually, set `"buffer_line_height": { "custom": 1.2 }`
and open a markdown preview containing the ASCII-art box from #62528.
The vertical rules should join into continuous lines, matching how the
same block renders in an editor, and should visibly separate again at
`"comfortable"`.

## 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 adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

Before
<img width="927" height="912" alt="Screenshot 2026-08-17 at 5 06 41 PM"
src="https://github.com/user-attachments/assets/be6213bf-f3aa-42fb-8784-1985b5379d74"
/>

After
<img width="915" height="994" alt="Screenshot 2026-08-17 at 5 06 54 PM"
src="https://github.com/user-attachments/assets/c9c7f395-50cb-437b-a423-2030da88e4f4"
/>



---

Release Notes:

- Fixed markdown code blocks not respecting the `buffer_line_height`
setting
35f63e406eAndrew Mitchell committed on 8/18/2026, 4:33:44 PM· committed by GitHubparent3624a5b
1 file changedLine totals unavailable