From bed093c91e4d15cd459fab7c98fc6932db1e34d5 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 15:02:17 +0100 Subject: [PATCH 1/3] Add test for bug https://github.com/kpdecker/jsdiff/issues/553 --- test/diff/word.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 764d8bcdca5403ba9d9018bdd0eaf1df600569b6 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 16:14:57 +0100 Subject: [PATCH 2/3] Fix bug --- src/diff/word.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From bb261d4bcbe2d479a9ee79f43b7e4f2cc3595093 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 16:24:08 +0100 Subject: [PATCH 3/3] Add release notes --- release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release-notes.md b/release-notes.md index 18ecb413..a37e9611 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.