Repository navigation
Commit 32030ed
text: Fix inline-code heading layout and list alignment (longbridge#3038)
## Summary
Markdown containing inline code uses a different rendering path, and
that path has two bugs:
- **Incorrect wrapping:** it could measure text using one font style,
then paint it using another—for example, measuring normal text but
drawing bold. Words wrapped inside a box that hadn’t reserved enough
height, so the heading overlapped the next paragraph.
- **Misaligned bullets:** it mixed two font-metric conventions when
calculating the baseline, shifting list text downward relative to its
bullet.
The fix makes measurement and painting use the same typography and
baseline calculations.
- Preserve inherited typography across deferred inline-flow measurement
and painting, preventing inline-code headings from wrapping outside
their allocated height and overlapping following text.
- Use shaped-line metrics consistently for baselines, fixing inline-code
list text sitting below its bullet.
- Add regressions for wrapping, preview zoom, painted bounds, and
native-compatible font metrics.
## Before / after
<img width="1878" height="404" alt="markdown-inline-size-bug"
src="https://github.com/user-attachments/assets/7b5c8262-33aa-4a43-b4a6-594b39588a54"
/>
**Original on the left; patched on the right**, in `example-markdown`.
The original wraps “with” into the following paragraph and misaligns
list text. The patch preserves reading order, block height, and baseline
alignment.
## Validation
- `cargo test -p gpui-base --lib` — **925 passed**
- `cargo fmt --all -- --check`
- `cargo clippy --all-targets --all-features -- -D warnings`
- `cargo build -p example-markdown`
- Visual comparison in the example app.
Co-authored-by: Richard Nelson <rnelson@atlassian.com>1 parent 42721ea commit 32030ed
3 files changed
Lines changed: 379 additions & 74 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| 214 | + | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
| |||
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
220 | 229 | | |
221 | 230 | | |
222 | 231 | | |
| |||
555 | 564 | | |
556 | 565 | | |
557 | 566 | | |
558 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
559 | 571 | | |
560 | 572 | | |
561 | 573 | | |
| |||
920 | 932 | | |
921 | 933 | | |
922 | 934 | | |
923 | | - | |
924 | | - | |
925 | | - | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
926 | 938 | | |
927 | 939 | | |
928 | 940 | | |
929 | 941 | | |
930 | 942 | | |
931 | 943 | | |
932 | 944 | | |
| 945 | + | |
| 946 | + | |
933 | 947 | | |
934 | 948 | | |
935 | 949 | | |
936 | 950 | | |
937 | 951 | | |
938 | 952 | | |
939 | 953 | | |
940 | | - | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
941 | 961 | | |
942 | 962 | | |
943 | 963 | | |
| |||
957 | 977 | | |
958 | 978 | | |
959 | 979 | | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
965 | 991 | | |
966 | 992 | | |
967 | 993 | | |
| |||
1043 | 1069 | | |
1044 | 1070 | | |
1045 | 1071 | | |
1046 | | - | |
| 1072 | + | |
| 1073 | + | |
1047 | 1074 | | |
1048 | 1075 | | |
1049 | 1076 | | |
| |||
0 commit comments