Skip to content

Conversation

atsjo
Copy link

@atsjo atsjo commented Mar 29, 2025

Support extending JSONFormatter with custom text diff operations, and fix a potential bug where MovedDelta is identified as a TextDiffDelta:

  if (itemDelta[2] === 3) {
    throw new Error(
      "JSONPatch (RFC 6902) doesn't support text diffs, disable textDiff option",
    );
  }

As of now I have to make my own copy of JSONFormatter to extend it. By accepting this PR this would be a cleaner integration for me, and give other the same easy way of supporting custom text diffing operations by extending JSONFormatter like this:

class MyJSONFormatter extends JSONFormater {
  protected override processTextDiff(ops: Op[], path: string, diff: string) {
    const lines = parseTextDiff(diff);
    for (const line of lines) ...
  }
}

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.

1 participant