ESM and TypeScript rewrite of Google's diff-match-patch for JavaScript
by antfuTypeScript
Last 12 weeks · 4 commits
5 of 6 standards met
Describe the bug For a specifically crafted input, would produce a delta that cause and to hang (infinite loop). The documentation for says that it would throw on invalid input, but it's not doing that for this case. Or this could be an issue with and where they are mishandling specific diffs. This is happening due to the empty edit/equality tuples. Reproducible on the latest . Reproduction: Potential fix (unverified): The original Java version has some extra check: https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/java/src/name/fraser/neil/plaintext/diff_match_patch.java#L938-L939 But missing from the JS (and TS) version: https://github.com/antfu/diff-match-patch-es/blob/4f35fb7fd57df68d69068cdee0780bb779f5497f/src/diff.ts#L880 Reproduction https://github.com/aforemendude/bugs-reproduction/tree/main/diff-match-patch-es-delta-inf-loop System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Describe the bug The current implementation operates on UTF-16 characters directly, which can cause it to split surrogate-pairs. When this happens, and can throw . Reproducible on the latest . Reproduction: Output: Reproduction https://github.com/aforemendude/bugs-reproduction/tree/main/diff-match-patch-es-urierror System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Describe the bug For line diffs, when is the final line (without trailing new line), identical inputs receive different character IDs and duplicate entries in the line table. This issue is happening to the latest . Reproduction: Following the line diff example here: https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs Output: Possible fix (unverified): https://github.com/antfu/diff-match-patch-es/blob/8c9aa5df9ba220c3742f8eab20f129ba9c04b685/src/diff.ts#L390 Change to or a . Please let me know if you want me to open a PR. Reproduction https://github.com/aforemendude/bugs-reproduction/blob/main/diff-match-patch-es-proto-edge-case/ System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [x] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Repository: antfu/diff-match-patch-es. Description: ESM and TypeScript rewrite of Google's diff-match-patch for JavaScript Stars: 197, Forks: 6. Primary language: TypeScript. Languages: TypeScript (99.9%), JavaScript (0.1%). License: Apache-2.0. Topics: dff-match-patch, diff, esm, javascript, typescript. Latest release: v2.0.1 (5d ago). Open PRs: 0, open issues: 2. Last activity: 5d ago. Community health: 85%. Top contributors: antfu, antfubot, anubra266, leekoho.