Repository navigation
fix(diff): keep bookmarks and comment ranges between blocks through compare, accept and reject (#1149) - #1177
Merged
Merged
Conversation
…ompare, accept and reject (#1149)
…eOffice findings (#1149)
…kers (#1149) Also regenerates the charter-collaboration golden redline: a bookmark whose end Word wrote between paragraphs now keeps that end instead of being closed zero-width at its start.
…over note, comment and move markers (#1149)
…d keep altChunk out of merged paragraphs (#1149) A table, row, cell, block wrapper or note whose only difference is a bookmark or comment range between its blocks pairs equal (the IR leaves those markers out) and was emitted as one side's copy, losing the other side's markers. Equal containers have the same blocks in order, so their markers are now merged boundary by boundary like a gap boundary. Accepting a deleted paragraph mark no longer puts a w:altChunk inside the merged paragraph, and the merge skips its marker bookkeeping for streams without loose children.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1149
Third of a three-PR stack for the comparison engine: #1169 (#1157), then #1173 (#1156), then this one. It is based on #1173's branch and will be retargeted to
mainas the stack merges.Why
Word often brackets a bookmark that spans whole paragraphs, or a table, with a
w:bookmarkStart/w:bookmarkEndplaced directly in the body or a table cell, as siblings of the paragraphs. The same goes for comment ranges. These markers were lost along the way:DocxDiff.Compareredline dropped them, and anyREFor table-of-contents field targeting the bookmark broke.RevisionProcessor.AcceptRevisionsandRejectRevisionsremoved them even from a document with no revisions. TheDocxComparefront door accepts its inputs before comparing, so it lost them before the comparison even started.How it works
LooseChildrenOfBlockStreamnow keeps every other child in front of the block it preceded. When a deleted paragraph mark merges two paragraphs, a marker between them goes inside the merged paragraph. Anything a paragraph may not hold, such asw:altChunk, stays in front of it. A stream with nothing outside its blocks takes the old path.w:ins/w:delthat sit directly in a block stream or in a block-levelw:customXml.IrBlockLevelMarkers.cs, called fromRenderBlockOpsWordShaped, which every block stream goes through):w:delorw:ins.ReconcileEqualContainerMarkers), because a marker-only change is invisible to the differ.NormalizeBookmarks. It no longer merges the per-side copies back into one bare pair.Validation
BlockLevelMarkerDiffTests(75 cases). Every original case failed on the base. Each compare case runs through bothDocxCompareandDocxDiff. Accept must equal the revised document and reject the original, marker positions included, and the redline must add no validation errors. The cases:w:sdtandw:customXmlwrappers;altChunk;TestFiles/WC/WC-BodyBookmarks-*).TestFiles/HistoryArchive/charter-collaboration-comparison.docxand its SHA changed. Two bookmarks that Word ended between paragraphs used to be closed zero-width at their start. They now keep their real end.Limits (follow-ups filed)
w:ins/w:delinside an inlinew:customXml.Adversarial review
One round of hostile review ran on the first four commits. It confirmed:
It found two real defects, both fixed in the last three commits:
w:altChunkinside a merged paragraph. That produced invalid OOXML and is now fixed.It also flagged an untested merged-paragraph path, now tested, and allocation work on marker-free documents, now fast-pathed.