From 68526b9b95fb2732c251ecadb46f228ee90281f3 Mon Sep 17 00:00:00 2001 From: Andrew Nagy <564256+tm1000@users.noreply.github.com> Date: Thu, 5 Sep 2024 06:33:41 -0700 Subject: [PATCH 1/4] Update release-notes.md (#552) Remove 'currently in beta' --- release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index 55248b2d..18ecb413 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,6 +1,6 @@ # Release Notes -## 6.0.0 (currently in beta) +## 6.0.0 This is a release containing many, *many* breaking changes. The objective of this release was to carry out a mass fix, in one go, of all the open bugs and design problems that required breaking changes to fix. A substantial, but exhaustive, changelog is below. From f9972d6993c268eb97530e6a4bc605303bcca77b Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 16:26:03 +0100 Subject: [PATCH 2/4] Fix links to commit lists in release-notes.md (#555) --- release-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-notes.md b/release-notes.md index 18ecb413..2bd56c62 100644 --- a/release-notes.md +++ b/release-notes.md @@ -4,7 +4,7 @@ This is a release containing many, *many* breaking changes. The objective of this release was to carry out a mass fix, in one go, of all the open bugs and design problems that required breaking changes to fix. A substantial, but exhaustive, changelog is below. -[Commits](https://github.com/kpdecker/jsdiff/compare/master...v6.0.0-staging) +[Commits](https://github.com/kpdecker/jsdiff/compare/v5.2.0...v6.0.0) - [#497](https://github.com/kpdecker/jsdiff/pull/497) **`diffWords` behavior has been radically changed.** Previously, even with `ignoreWhitespace: true`, runs of whitespace were tokens, which led to unhelpful and unintuitive diffing behavior in typical texts. Specifically, even when two texts contained overlapping passages, `diffWords` would sometimes choose to delete all the words from the old text and insert them anew in their new positions in order to avoid having to delete or insert whitespace tokens. Whitespace sequences are no longer tokens as of this release, which affects both the generated diffs and the `count`s. @@ -40,7 +40,7 @@ This is a release containing many, *many* breaking changes. The objective of thi ## v5.2.0 -[Commits](https://github.com/kpdecker/jsdiff/compare/v5.1.0...master) +[Commits](https://github.com/kpdecker/jsdiff/compare/v5.1.0...v5.2.0) - [#411](https://github.com/kpdecker/jsdiff/pull/411) Big performance improvement. Previously an O(n) array-copying operation inside the innermost loop of jsdiff's base diffing code increased the overall worst-case time complexity of computing a diff from O(n²) to O(n³). This is now fixed, bringing the worst-case time complexity down to what it theoretically should be for a Myers diff implementation. - [#448](https://github.com/kpdecker/jsdiff/pull/411) Performance improvement. Diagonals whose furthest-reaching D-path would go off the edge of the edit graph are now skipped, rather than being pointlessly considered as called for by the original Myers diff algorithm. This dramatically speeds up computing diffs where the new text just appends or truncates content at the end of the old text. From 7d113b61e6f43fbb89f7d1388eac339ebea9eeb5 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 17:31:31 +0100 Subject: [PATCH 3/4] Fix diffWords treating numbers and underscores as not being word characters (#554) * Add test for bug https://github.com/kpdecker/jsdiff/issues/553 * Fix bug * Add release notes --- release-notes.md | 4 ++++ src/diff/word.js | 2 +- test/diff/word.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index 2bd56c62..b1c09912 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,5 +1,9 @@ # Release Notes +## Future 7.0.0 release + +- [#554](https://github.com/kpdecker/jsdiff/pull/554) **`diffWords` treats numbers and underscores as word characters again.** This behaviour was broken in v6.0.0. + ## 6.0.0 This is a release containing many, *many* breaking changes. The objective of this release was to carry out a mass fix, in one go, of all the open bugs and design problems that required breaking changes to fix. A substantial, but exhaustive, changelog is below. diff --git a/src/diff/word.js b/src/diff/word.js index 580c189f..fd9284f8 100644 --- a/src/diff/word.js +++ b/src/diff/word.js @@ -19,7 +19,7 @@ import { longestCommonPrefix, longestCommonSuffix, replacePrefix, replaceSuffix, // - U+02DC ˜ ˜ Small Tilde // - U+02DD ˝ ˝ Double Acute Accent // Latin Extended Additional, 1E00–1EFF -const extendedWordChars = 'a-zA-Z\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}'; +const extendedWordChars = 'a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}'; // Each token is one of the following: // - A punctuation mark plus the surrounding whitespace diff --git a/test/diff/word.js b/test/diff/word.js index f81a4e45..418a8ae5 100644 --- a/test/diff/word.js +++ b/test/diff/word.js @@ -31,6 +31,34 @@ describe('WordDiff', function() { '.' ]); }); + + // Test for bug reported at https://github.com/kpdecker/jsdiff/issues/553 + it('should treat numbers as part of a word if not separated by whitespace or punctuation', () => { + expect( + wordDiff.tokenize( + 'Tea Too, also known as T2, had revenue of 57m AUD in 2012-13.' + ) + ).to.deep.equal([ + 'Tea ', + ' Too', + ', ', + ' also ', + ' known ', + ' as ', + ' T2', + ', ', + ' had ', + ' revenue ', + ' of ', + ' 57m ', + ' AUD ', + ' in ', + ' 2012', + '-', + '13', + '.' + ]); + }); }); describe('#diffWords', function() { From ad8f0eb9f4cea9a4b6abdede878e7a3d0f555a73 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Fri, 6 Sep 2024 23:08:41 +0100 Subject: [PATCH 4/4] Prep for 7.0.0 release (#556) --- package.json | 2 +- release-notes.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d92dccbf..400c8dd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diff", - "version": "6.0.0", + "version": "7.0.0", "description": "A JavaScript text diff implementation.", "keywords": [ "diff", diff --git a/release-notes.md b/release-notes.md index b1c09912..21b5d41d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,6 +1,8 @@ # Release Notes -## Future 7.0.0 release +## 7.0.0 + +Just a single (breaking) bugfix, undoing a behaviour change introduced accidentally in 6.0.0: - [#554](https://github.com/kpdecker/jsdiff/pull/554) **`diffWords` treats numbers and underscores as word characters again.** This behaviour was broken in v6.0.0.