text: Break inline flow at hard newlines (#2676)
Closes #2673 ## Description Fix a panic when a Markdown paragraph contains a newline before an inline HTML image, for example: ```markdown Hi [<img src="whatever">](https://google.com/) ``` `InlineFlow` previously passed a text range containing a hard line break to GPUI's single-line text shaper. GPUI's line wrapper skips `\n` during width calculation but does not split the range, so the newline later reached `shape_line`, which rejects multiline input and panicked. This change splits inline-flow content at hard newlines first, then applies soft wrapping to each hard line independently. It also adds a regression test using the issue's Markdown structure. AI assistance: Codex assisted with root-cause analysis, implementation, testing, and PR wording. The final changes were reviewed and tested manually. ## Before / After The same Markdown was tested in the Markdown Editor before and after this change: ```markdown Hi [<img src="https://github.githubassets.com/favicons/favicon.svg">](https://google.com/) ``` ### Before The application panics while laying out the Markdown because a newline reaches the text shaper: <img width="1947" height="344" alt="Before: the Markdown example panics with text argument should not contain newlines" src="https://github.com/user-attachments/assets/947e1614-1445-44b6-a11c-527a73bd2087" /> ### After The Markdown renders successfully, with the linked inline image appearing on the line after `Hi`: <img width="2727" height="1617" alt="After: the Markdown Editor renders the text and linked inline image" src="https://github.com/user-attachments/assets/69f0bcef-c11a-4e5b-b7aa-268cebd5ab17" /> ## How to Test ```bash cargo test -p gpui-component inline_html_image_after_newline_does_not_panic cargo test -p gpui-component cargo fmt --package gpui-component -- --check ``` Results: - Regression test passes. - All 407 `gpui-component` tests pass. - Formatting check passes. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI-generated code is accurate. - [X] Passed `cargo run` for story tests related to the changes. - [x] Platform-specific performance testing is not applicable to this fix.
L
luren committed
26cc9366abb27ccedce386ac99a615a8fa7018da
Parent: 55968d1
Committed by GitHub <noreply@github.com>
on 8/11/2026, 4:04:51 AM