kpdecker / jsdiff

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

Handle case where the user explicitly passes `maxEditLength: 0` the way you'd expect #464

Closed ExplodingCabbage closed 6 months ago

ExplodingCabbage commented 6 months ago

Previously, this was treated as if the maxEditLength option wasn't provided at all, which seems surprising. Obviously, passing maxEditLength: 0 isn't usually gonna be a very useful thing to do, but you can imagine a system where there's a configurable max edit distance between two texts with a UI that lets you put it all the way down to 0, and jsdiff is being used both to check that the max distance is being adhered to and to display the diff. In such a case, the current behaviour would introduce a surprising bug in the maxEditLength: 0 case.

This PR makes jsdiff instead treat maxEditLength: 0 as specifying a max edit length of 0.