Skip to content

feat(api): wrap inline highlight chips across lines#226

Merged
DemchaAV merged 2 commits into
developfrom
feat/inline-highlight-wrap
Jun 22, 2026
Merged

feat(api): wrap inline highlight chips across lines#226
DemchaAV merged 2 commits into
developfrom
feat/inline-highlight-wrap

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

Inline highlight chips (the GitHub inline code look + status badges) shipped in
#225 as a single atomic fragment — a multi-word chip stayed on one line and a chip
wider than the column overflowed. This adds wrapping: a chip flows and breaks with
the surrounding line, like a browser highlight.

What changed

  • A chip's text now tokenizes into WORD tokens tagged with a shared group
    (InlineHighlightRun identity); the words wrap via the normal greedy fit loop.
    TextFlowSupport.toInlineParagraphLine coalesces the same-group tokens on each
    visual line into one ParagraphTextSpan, so a wrapped chip paints one continuous
    rounded fill per line-fragment — not a box per word.
  • Padding sits on the run's outer edges (lead pad on the first word, trail pad on
    the last), so a continuation fragment is open on its inner break edge (slice). The
    soft-wrap space at a break is collapsed on BOTH edges, so the fill hugs the visible
    glyphs and the seam space stays out of line width (no alignment drift).
  • A single over-wide chip WORD stays atomic on its own line. Non-chip text rendering
    is unchanged — the forwhile span-emission rewrite is byte-identical for plain
    / image / shape / SVG spans.

Verification

./mvnw test -pl .BUILD SUCCESS, full suite green. New InlineHighlightRenderTest
coverage:

  • a multi-word chip wraps to one coalesced fill per fragment with slice padding (first fragment lead-padded, continuation open-left, final closed-right);
  • the wrapped fill spans an extra line vs a single-line chip;
  • a width sweep (78–220 pt) asserts no fragment leads or trails with a soft-wrap space;
  • a wrapped chip keeps its full text across the break with plain text on both sides;
  • two adjacent distinct chips stay separate;
  • a wrapped linked chip is clickable on each line fragment.

InlineHighlightExample gains a wrapping section, regenerated and visually verified.

Lane: shared-engine (layout) + canonical DSL. CHANGELOG updated.

Follow-up to #225 (inline highlight chips, already merged). Deferred cosmetics: the
chip band is sized to the line's text height rather than the chip's own font, and a
single over-wide chip word can still overflow on center/right alignment — both minor,
not addressed here.

DemchaAV added 2 commits June 22, 2026 20:50
…scing)

A multi-word highlight chip now tokenizes into words tagged with a shared
group; the words wrap with the surrounding line via the normal fit loop, and
toInlineParagraphLine coalesces the same-group tokens on each visual line into
one ParagraphTextSpan — so a wrapped chip paints one continuous rounded fill
per line-fragment, not a box per word. Horizontal padding sits on the run's
outer edges (lead on the first word, trail on the last), so a continuation
fragment is open on the inner break; the soft-wrap space at a break is
collapsed so the fill ends at the last visible glyph. A single over-wide chip
word stays atomic on its own line; non-chip text rendering is unchanged.

Tests: a multi-word chip wraps to one coalesced fill per fragment (slice
padding); the wrapped fill spans an extra line vs a single-line chip; a wrapped
chip keeps its full text across the break with plain text on both sides; two
adjacent distinct chips stay separate; a wrapped linked chip is clickable per
fragment. The example gains a wrapping section; CHANGELOG updated.
A wrapped highlight chip whose break lands so the inter-word space leads the
continuation line kept that space (chip tokens are exempt from the leading
trimmer) — the mirror of the already-collapsed trailing case — so the
continuation fill started a space-width left of the first glyph. Make the
seam-space collapse symmetric: drop a leading inter-word space (leadPad == 0)
as well as a trailing one. Adds a width-sweep test asserting no chip fragment
leads or trails with a soft-wrap space, and locks the final fragment's
closed-right pad.
@DemchaAV DemchaAV merged commit 83f4b35 into develop Jun 22, 2026
11 checks passed
@DemchaAV DemchaAV deleted the feat/inline-highlight-wrap branch June 22, 2026 20:32
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