Skip to content

Patches created with v5 can not be applied with v7 #588

Description

@markdon

Repro: https://codesandbox.io/p/devbox/x5s3pc

/** Combine a set of revisions in to their full text */
export async function textOfRevisions(_revisions: Revision[]) {
  const revisions = assertZeroRevision(_revisions);
  return revisions.reduce((acc, r, index) => {
    if (r.sequence === 0) return r.text;
    const thisText = diff7.applyPatch(acc, r.text); // VERSION 7 FAILS TO APPLY
    // const thisText = diff5.applyPatch(acc, r.text);
    if (thisText === false) throw new Error(`Failed to apply patch ${index}`);
    if (!md5Match(thisText, r.checksum)) {
      throw new Error(`Checksum mismatch on revision ${index}`);
    }
    return thisText;
  }, "");
}

I'm storing a full original text document and patches for updates to that document.

After updating diff to version 7, the patches I had stored could not be applied.
diff.applyPatch(<originalText>, <patch>); would return false.

Is this expected as part of a breaking change? I don't see any mention of breaking changes or migration needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions