-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
The inplace modifier's insertDeletedRun and insertMoveFromRun functions pack all collapsed field atoms into a single <w:r>, breaking multi-run field structure. This causes orphaned fldChar elements and leaked instrText that renders as visible text in Word.
Root Cause
Asymmetry in field handling between insert and delete paths:
handleInserted(inPlaceModifier.ts): Correctly callsgetAtomRuns(atom)and wraps each run individually — multi-run field structure preserved.handleDeleted→insertDeletedRun: CallscloneRunWithAtomContent(sourceRun, atom)which clones only the FIRST run and packs ALL field elements into it.handleMovedSource→insertMoveFromRun: Same bug.
Observed Output (before fix)
<w:del>
<w:r>
<w:fldChar w:fldCharType="begin"/>
<w:instrText> PAGEREF _Toc123 \h </w:instrText>
<w:fldChar w:fldCharType="separate"/>
<w:delText>23</w:delText>
<w:fldChar w:fldCharType="end"/>
</w:r>
</w:del>Expected Output (after fix)
<w:del>
<w:r><w:fldChar w:fldCharType="begin"/></w:r>
<w:r><w:instrText> PAGEREF _Toc123 \h </w:instrText></w:r>
<w:r><w:fldChar w:fldCharType="separate"/></w:r>
<w:r><w:delText>23</w:delText></w:r>
<w:r><w:fldChar w:fldCharType="end"/></w:r>
</w:del>Fix
Added filterRun parameter to getInsertableAtomContentElements (Approach A). Both insertDeletedRun and insertMoveFromRun now call getAtomRuns() and emit one cloned run per original source run.
Tests
Regression tests in collapsed-field-inplace.test.ts:
- Dedicated-run field (PAGEREF): 6 tests
- Mixed-run field (REF with surrounding text): 4 tests
- Edge cases: 1 test
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working