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 55248b2d..21b5d41d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,10 +1,16 @@ # Release Notes -## 6.0.0 (currently in beta) +## 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. + +## 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. -[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 +46,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. 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() { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy