Skip to content

fix(word): remove the paragraph whose mark was moved away - #552

Merged
sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
rmorgans:fix/moved-paragraph-mark
Oct 18, 2026
Merged

sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
rmorgans:fix/moved-paragraph-mark

Conversation

@rmorgans

@rmorgans rmorgans commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

When a whole paragraph is moved with tracking (w:moveFrom/w:moveTo, including the paragraph mark in w:pPr/w:rPr), both Accept and Reject leave an empty paragraph behind.

Reproduction. Paragraphs Before | Moved (moveFrom, mark moved) | Middle | Moved (moveTo, mark moved) | After.

  • Accept gives Before | (empty) | Middle | Moved | After; Word gives Before | Middle | Moved | After.
  • Reject gives Before | Moved | Middle | (empty) | After; Word gives Before | Moved | Middle | After.

Cause. AcceptMoveFromMoveToTransform removes every w:moveFrom, including the paragraph-mark marker, before AcceptDeletedAndMoveFromParagraphMarks can join that paragraph with the next.

Fix. Treat a moved-from paragraph mark as a deleted paragraph mark so the existing handling joins it.

Baselines. RP015-MoveFrom-MoveTo-Accepted.docx and -Rejected.docx contained the empty paragraph; I removed only that paragraph from each (everything else unchanged). The RP018 baselines (the same move inside a content control) already expected no empty paragraph.

Test. RP056_MovedParagraphLeavesNoEmptyParagraph.


Found while using RevisionProcessor to check that Reject All of a tracked-change redline gives back the original document. Expected results are Microsoft Word for Mac 16.113's own Accept All / Reject All on the same markup. The regression test fails on master and passes with the fix.

Merging. Rebased on master after #550, #551 and #555 landed. The test is now in the new file RevisionProcessorTests.MovedParagraphMark.cs. The only edit to RevisionProcessorTests.cs makes the class partial, the same one-word edit as in #554 and #556, so this PR, those two and #553 merge cleanly in any order. I checked this by merging all four onto master: no conflicts, and the full suite passes.

Prepared with an AI coding agent (Claude); I reviewed the change and ran the tests.

AcceptMoveFromMoveToTransform removed every w:moveFrom, including the
marker of a moved-from paragraph mark (w:pPr/w:rPr/w:moveFrom), before
AcceptDeletedAndMoveFromParagraphMarks could join that paragraph with
the next. Accept All therefore left an empty paragraph where a moved
paragraph had been, and Reject All (which swaps moveFrom and moveTo,
then accepts) left one where it had gone. Word leaves neither.

Keep a moved-from paragraph mark as a deleted one so the existing
deleted-paragraph-mark handling applies. The RP015 baselines recorded
the empty paragraph; drop it from both (RP018, the same move inside a
content control, already expected none).

The test lives in its own partial-class file so that concurrent
RevisionProcessor fixes do not edit the same lines.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fix reuses existing paragraph-joining logic and covers both operations with regression tests, with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes Word revision processing so accepting or rejecting a moved paragraph does not leave an empty paragraph behind.

Changes:

  • Routes moved-from paragraph marks through existing deleted-mark handling.
  • Adds regression coverage for both acceptance and rejection.
  • Makes the test class partial to support the separate regression file.
File Description
Clippit/​Word/​RevisionProcessor.cs Preserves moved-from paragraph marks for paragraph joining.
Clippit.Tests/​Word/​RevisionProcessorTests.MovedParagraphMark.cs Tests paragraph order and revision cleanup for both operations.
Clippit.Tests/​Word/​RevisionProcessorTests.cs Makes the test class partial.

Review effort: Balanced

@sergey-tihon
sergey-tihon merged commit 679d3f9 into sergey-tihon:master Oct 18, 2026
11 checks passed
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.

3 participants