Skip to content

simplify: unify stepRichInlineLine/Stats and remove containsCJKText wrapper#138

Open
shaun0927 wants to merge 1 commit intochenglou:mainfrom
shaun0927:simplify/rich-inline-unify-stats
Open

simplify: unify stepRichInlineLine/Stats and remove containsCJKText wrapper#138
shaun0927 wants to merge 1 commit intochenglou:mainfrom
shaun0927:simplify/rich-inline-unify-stats

Conversation

@shaun0927
Copy link
Copy Markdown

Fixes #136

Changes

Two small simplifications, bundled together since they are each one-liners with no cross-dependencies. Neither changes behavior — all 84 tests pass.

1. Remove stepRichInlineLineStats (~130 lines deleted)

stepRichInlineLineStats was a near-duplicate of stepRichInlineLine whose only difference was skipping the optional collectFragment callback. Since the callback is already optional (called via collectFragment?.()), passing undefined achieves the same result.

Why this matters: PR #132 had to apply the same overflow guard to both functions in parallel — the exact duplication pattern that makes one-sided patches easy to miss. Unifying the two functions ensures future fixes apply to both the materializing and stats-only paths automatically.

2. Inline containsCJKText() wrapper (4 lines deleted)

containsCJKText() was a single-call-site passthrough to the already-public isCJK(). Replaced the call at line 1210 with isCJK(text) directly. Similar to the isCJK dedup in PR #118.

Test plan

  • bun test src/layout.test.ts — 84 tests pass, 0 fail
  • No public API changes — only internal function removal
  • measureRichInlineStats still returns identical results to walkRichInlineLineRanges across all existing test cases

…rapper

Remove stepRichInlineLineStats, a ~130-line near-duplicate of
stepRichInlineLine. The only difference was whether the optional
collectFragment callback fired — passing undefined achieves the
same result. PR chenglou#132 demonstrated the drift risk by having to
apply the same overflow guard to both functions in parallel.

Also inline the single-call-site containsCJKText() wrapper, which
was a passthrough to the already-public isCJK(). Similar to the
isCJK dedup in PR chenglou#118.

Neither change affects behavior. All 84 tests pass.
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.

Simplify rich-inline: unify stepRichInlineLine/Stats and remove containsCJKText wrapper

1 participant