Skip to content

Fix whitespace collapsing removing spaces at style span boundaries - #17

Open
nicoburns wants to merge 1 commit into
mainfrom
fix-inline-span-whitespace-collapse
Open

Fix whitespace collapsing removing spaces at style span boundaries#17
nicoburns wants to merge 1 commit into
mainfrom
fix-inline-span-whitespace-collapse

Conversation

@nicoburns

Copy link
Copy Markdown
Member

LLM Contributions: This PR (code and description) was produced by Devin, requested and reviewed by @nicoburns.

TreeStyleBuilder in WhiteSpaceCollapse::Collapse mode was trimming whitespace at every style span boundary:

  • push_style_span set is_span_first = true, so the first text of every span had its leading whitespace stripped even when the preceding text ended in a non-space character.
  • pop_style_span committed with is_span_last = true, stripping the span's trailing whitespace unconditionally.

So "Singer-songwriter" + <span>"\u{a0} · "</span> + "actress" collapsed to Singer-songwriter·actress — dropped separators and no soft-break opportunities. In Blitz this breaks Wikipedia infoboxes (hlists rendered as display: inline <li>s with ::after separators): the unbreakable text inflates the intrinsic width, overflowing the cell and misplacing the table columns (see https://en.wikipedia.org/wiki/Dolly_Parton, the about=#mwt9 infobox).

Fix: leading trim now only happens at the start of the whole text or after existing trailing whitespace (is_span_first is no longer reset per-span), and trailing trim only happens at the end of the whole layout (pop_style_span commits with is_span_last = false; finish still trims the end).

Known limitation: if the layout's final text ends inside a span with trailing collapsible whitespace, that single trailing space is now kept (previously the per-span trim removed it).

Blitz rendering of the Dolly Parton infobox with this fix (previously the text overflowed the infobox and the columns were misplaced):

fixed infobox

Changelog

Fixed

  • Whitespace collapsing in TreeBuilder no longer removes spaces at style span boundaries.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/dabfa60a5ab3411bb6c6225f9f81a79e
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/dabfa60a5ab3411bb6c6225f9f81a79e?variant=devin-insiders

@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant