Summary
Two small simplification opportunities in the v0.0.5 code, both pure refactors with no behavior change.
1. stepRichInlineLine and stepRichInlineLineStats share ~180 lines of near-identical logic
rich-inline.ts:211–387 and rich-inline.ts:389–519 implement the same line-stepping loop. The only difference is whether a collectFragment callback fires. Since stepRichInlineLine already accepts an optional collectFragment parameter, the stats variant could be replaced with stepRichInlineLine(flow, maxWidth, cursor, undefined).
Evidence of drift risk: 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.
I verified the two functions produce identical lineCount and maxLineWidth across multiple item/width combinations (simple text, CJK multi-item, atomic chips with extraWidth, mixed items), so unification would not change behavior.
2. containsCJKText() is a single-call-site passthrough to isCJK()
// analysis.ts:161–163
function containsCJKText(text: string): boolean {
return isCJK(text)
}
One call site at line 1214. Similar to the isCJK dedup and no-op removal in PR #118.
Motivation
Both align with the repo's holistic-pass simplification principle. Neither changes behavior — the first reduces the surface for future one-sided patches in rich-inline, and the second removes a trivial indirection.
Happy to submit a PR if these look reasonable.
Summary
Two small simplification opportunities in the v0.0.5 code, both pure refactors with no behavior change.
1.
stepRichInlineLineandstepRichInlineLineStatsshare ~180 lines of near-identical logicrich-inline.ts:211–387andrich-inline.ts:389–519implement the same line-stepping loop. The only difference is whether acollectFragmentcallback fires. SincestepRichInlineLinealready accepts an optionalcollectFragmentparameter, the stats variant could be replaced withstepRichInlineLine(flow, maxWidth, cursor, undefined).Evidence of drift risk: 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.
I verified the two functions produce identical
lineCountandmaxLineWidthacross multiple item/width combinations (simple text, CJK multi-item, atomic chips withextraWidth, mixed items), so unification would not change behavior.2.
containsCJKText()is a single-call-site passthrough toisCJK()One call site at line 1214. Similar to the
isCJKdedup and no-op removal in PR #118.Motivation
Both align with the repo's holistic-pass simplification principle. Neither changes behavior — the first reduces the surface for future one-sided patches in rich-inline, and the second removes a trivial indirection.
Happy to submit a PR if these look reasonable.