text: Keep a line with inline code as tall as a plain line - #3240
Merged
Merged
Conversation
A line containing inline code is laid out by `InlineFlow`, a plain line by GPUI's own text layout, and the two disagreed on the line height: - Every text run added its own centered leading to the line, so a run whose ascent/descent proportions differ from the body font's (the smaller mono inline code) made the line taller, on one side only. The body strut was also stretched to the font's ascent + descent when that exceeds the line height, which a plain line never does. - The line height came from `Window::line_height`, which rounds to a whole logical pixel before snapping to device pixels; `StyledText` does not, so at fractional scale factors the flow line was a device pixel taller. Runs now join the line by their glyph box, may overflow it as far as body glyphs do, and get their leading back symmetrically when positioned; the line height is resolved as `StyledText` resolves it. Fixes #3162 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3162
Description
In a Markdown
TextView, a line containing inline code was taller than a plain line, so a tight list with one code item was unevenly spaced (the code item looked pushed down). A line with inline code is laid out byInlineFlow, a plain line by GPUI's text layout, and they disagreed on the line height in two ways:Window::line_height, which rounds to a whole logical pixel before snapping to device pixels.StyledTextdoes not round first, so at fractional scale factors (e.g. 1.6: 25.888 → 26 → 26.25 instead of 25.625) the flow line was one device pixel taller.Changes in
crates/base/src/text/inline_flow.rs:StyledTextdoes.Measured in the real app at scale 1.6 with the issue's list (plus a CJK list), gaps between bullets in device pixels:
No public API changes.
How to Test
cargo test -p gpui-base --lib; new regressionsinline_code_line_is_as_tall_as_a_plain_line(scale 1.6/2, zoom 1/1.25) andinline_code_line_is_as_tall_as_a_plain_line_when_glyphs_overflow_itfail before this change.- plain item one\n- item with \inline code`\n- plain item three` on a fractional-scale display; the items are evenly spaced.🤖 Generated with Claude Code