Skip to content

Untracked replace inside another author's insertion that holds a nested deletion replaces the wrong span (0.27.0) #22

Closed

Description

@Dmitry-Kov

Thanks for the fast fix of #13 — in 0.27.0 the tracked case (replace --track)
now gives the editor's own w:ins at the right place. The untracked case on the
same paragraph still edits the wrong words.

Version: docx-cli 0.27.0 (npm tarball, tag v0.27.0)

Paragraph (the one from #13: Reviewer A's pending insertion holding
Reviewer B's pending deletion of "any "):

<w:p>
  <w:r><w:t xml:space="preserve">Fees are due. </w:t></w:r>
  <w:ins w:id="1" w:author="Reviewer A" w:date="2026-09-01T00:00:00Z">
    <w:r><w:t xml:space="preserve">The Client may withhold </w:t></w:r>
    <w:del w:id="2" w:author="Reviewer B" w:date="2026-09-02T00:00:00Z">
      <w:r><w:delText xml:space="preserve">any </w:delText></w:r>
    </w:del>
    <w:r><w:t>disputed amount.</w:t></w:r>
  </w:ins>
</w:p>

Command:

docx replace nested-deletion.docx "disputed amount" "disputed sum"

It prints replace 1 occurrence replaced and exits 0.

Actual — the first words of the insertion are replaced, not the target:

<w:ins w:id="1" w:author="Reviewer A" w:date="2026-09-01T00:00:00Z">
  <w:r><w:t xml:space="preserve">disputed sum</w:t></w:r>
  <w:r><w:t xml:space="preserve">withhold </w:t></w:r>
  <w:del ...><w:r><w:delText xml:space="preserve">any </w:delText></w:r></w:del>
  <w:r><w:t>disputed amount.</w:t></w:r>
</w:ins>

With all changes accepted the paragraph reads
Fees are due. disputed sumwithhold disputed amount.

Expected: Fees are due. The Client may withhold disputed sum. with all
changes accepted, Reviewer B's deletion of "any " and Reviewer A's insertion
otherwise unchanged — as replace --track now produces apart from the
tracking.

Possibly related to #16 / #21 (another wrapper nested in an insertion), though
here the match lies entirely after the nested deletion and crosses no wrapper;
the replacement lands at the start of the insertion instead.

The same happens on a larger document in a document-editing benchmark, in
both repeats, with 0.26.0 and 0.27.0 alike (the 0.27.0 output is byte-for-byte
the 0.26.0 one). The run and the files are recorded here:
https://github.com/Dmitry-Kov/ooxml-integrity/blob/main/evidence/review-history-recheck/nested-deletion.json

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions