Closed khechoshvili closed 7 months ago
This does not look like a bug to me, more like "works as designed". diff tries to find the shortest sequence of characters that have to be changed to get from one string to another.
The chosen solution is on the shortest path. even if it looks weird: You have 1 removed character and 19 added characters (notice the d in the middle that is not inserted but reused). That's 20 changed characters in total.
If you count your manual actions, you have:
That's 22 changed characters, which is not an optional solution because it is not the shortest sequence to get from the first string to the second.
Yeah, this is the diff that minimises the number of characters inserted & deleted, which is what diffChars
is meant to give you.
I encountered bug with this code.
See here.
There are three changes which I made in the "other" variable, namely:
However, please see the screenshot. It generates a weird diff:![screenshot_from_2023-06-22_13-45-49](https://github.com/kpdecker/jsdiff/assets/66695021/a45cfd8f-caf7-4c0e-8880-aaf51eced6a4)
It didn't notice removal of "d".
Can someone explain this behavior? (I do have rough explanation why such diff was generated, but still this doesn't seem to be a optimal diff). So is this a bug?