kpdecker / jsdiff

A javascript text differencing implementation.
BSD 3-Clause "New" or "Revised" License
7.92k stars 496 forks source link

diffWords is not detecting a deleted space at the end of text. #402

Closed firststeven closed 8 months ago

firststeven commented 1 year ago

Any ideas?

Can anyone else reproduce this issue?

V5.0

ExplodingCabbage commented 8 months ago

This is expected. If you want to catch whitespace differences, you need diffWordsWithSpace. Per the README:

Diff.diffWords(oldStr, newStr[, options]) - diffs two blocks of text, comparing word by word, ignoring whitespace. ... Diff.diffWordsWithSpace(oldStr, newStr[, options]) - diffs two blocks of text, comparing word by word, treating whitespace as significant.

(I was surprised to discover it too.)