Skip to content

Fix rich-inline punctuation boundary wrapping#194

Open
luyh7 wants to merge 1 commit into
chenglou:mainfrom
luyh7:codex/rich-inline-punctuation-boundary
Open

Fix rich-inline punctuation boundary wrapping#194
luyh7 wants to merge 1 commit into
chenglou:mainfrom
luyh7:codex/rich-inline-punctuation-boundary

Conversation

@luyh7
Copy link
Copy Markdown

@luyh7 luyh7 commented May 31, 2026

Summary

  • Keep rich-inline item boundaries from wrapping before line-start-prohibited punctuation when there is no collapsed whitespace gap.
  • Reuse the core punctuation sets so split inline items such as Hello + . stay attached.
  • Add a regression test covering materialized rich-inline lines and stats.

Why

Adjacent inline items should not introduce an extra line break before punctuation that browsers keep attached to the previous text node. This addresses #177.

Validation

  • /home/luyh7/tmp/.tools/bun-1.3.14/package/bin/bun test src/layout.test.ts
  • node node_modules/typescript/bin/tsc --noEmit
  • node node_modules/typescript/bin/tsc -p tsconfig.build.json
  • git diff --check

@luyh7 luyh7 marked this pull request as ready for review May 31, 2026 13:04
@rf-
Copy link
Copy Markdown

rf- commented Jun 1, 2026

If it's true that browsers behave exactly the same way for adjacent spans that they do for a single text node, it seems like doing this correctly would require a much bigger refactor so that all of the logic in buildMergedSegmentation can be applied across items. That's pretty difficult though—I'm taking a stab at it but haven't fully proven it out yet, and it's hard to not regress on performance at all in the simple case.

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.

2 participants