Andrew Mitchell 10087cd21b 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
2026-08-18 16:33:44 +00:00
2026-08-12 08:35:43 +00:00
2026-07-29 13:03:22 +00:00
2026-01-22 23:57:26 +05:30
2026-07-27 05:59:53 +00:00
2026-08-18 14:23:30 +00:00
2026-08-18 14:23:30 +00:00
WIP
2023-12-14 09:25:14 -07:00
2026-08-09 22:29:52 +00:00
2026-08-09 22:29:52 +00:00
2025-02-04 09:02:59 -05:00
2025-10-27 13:27:59 -04:00
2026-06-27 15:06:29 +00:00
2025-10-17 18:58:14 +00:00
2026-03-17 16:34:35 +00:00

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.

Sponsorship

Zed is developed by Zed Industries, Inc., a for-profit company.

If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.

S
Description
No description provided
Readme
411 MiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 94.9%
JSON-with-Comments 2.7%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.5%