Skip to content

dmp: @cocalc/diff-match-patch ^1.1.1 (whole-text patches for small edits to long texts; lost high-surrogate edits) - #33

Merged
williamstein merged 2 commits into
mainfrom
fix/dmp-1.1.1
Oct 23, 2026
Merged

williamstein merged 2 commits into
mainfrom
fix/dmp-1.1.1

Conversation

@williamstein

Copy link
Copy Markdown
Contributor

Moves patchflow to @cocalc/diff-match-patch ^1.1.1, which fixes two bugs that 0.12–0.15 shipped with via 1.1.0.

  • Small edits to long texts became whole-text patches. Under the 25M diffWorkLimit, texts over about 780 KB in total couldn't pay for stripping their common prefix and suffix, so the diff was the whole text deleted and inserted. A one-line edit to 800 KB gave a 1.68 MB patch. It is now a patch of the line (75 B), up to 4 MB and beyond.
  • Edits silently lost when they change only a high surrogate. For example, 😀 → 🨀 gave an empty patch, so makePatch/applyPatch left the old text. In random emoji edits at 25M, about 12% of edits were lost on 1.1.0, and none are now. The author's device kept the intended text (and its recorded hash), while the stored patch lacked the edit.

Changes:

  • package.json: @cocalc/diff-match-patch ^1.1.0 → ^1.1.1.

  • pnpm-lock.yaml: diff-match-patch 1.1.0 → 1.1.1. pnpm also re-points tinyglobby's picomatch peer from 4.0.4 to 4.0.7, which was already in the lockfile.

  • src/dmp-work-limit.test.ts, regression tests:

    • one-line edits to 800 KB and 2 MB texts give a patch under 1,000 bytes, and apply;
    • 😀 → 🨀, in short and long texts and in a 800,002-character text, apply exactly.

    Against 1.1.0, three of these fail; with 1.1.1 all pass.

Checks: pnpm check (tests, lint, build) passes, with 246 tests passed and 1 skipped.

Still in diff-match-patch and unchanged here: patch_toText can throw on surrogate pairs that patch_addContext splits. patchflow stores patch objects and doesn't call it.

No version bump: "release: 0.16.0" follows as its own PR, as for 0.15.0.

…ch; an emoji changed in its high surrogate is not lost (both need @cocalc/diff-match-patch 1.1.1)
…small under the work budget; edits changing only a high surrogate are no longer lost)

The lockfile moves only @cocalc/diff-match-patch 1.1.0 -> 1.1.1; pnpm also
re-points tinyglobby's picomatch peer from 4.0.4 to 4.0.7 (already locked).
@williamstein
williamstein merged commit 547de21 into main Oct 23, 2026
1 check passed
@williamstein williamstein mentioned this pull request Oct 23, 2026
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