mitsuhiko / similar

A high level diffing library for rust based on diffs
https://insta.rs/similar
Apache License 2.0
949 stars 31 forks source link

Semantic Cleanups for Char Diffs #25

Open mitsuhiko opened 3 years ago

mitsuhiko commented 3 years ago

Related to #24 similar could benefit of having semantic cleanups for char level diffs.

https://neil.fraser.name/writing/diff/

faassen commented 1 year ago

I just dug into this a bit, so I thought I'd leave this here for future reference:

There are implementations by Neil Fraser here, likely with more up to date versions of the code:

https://github.com/google/diff-match-patch/

There's a port to Rust of the C++ implementation here:

https://github.com/dtolnay/dissimilar

So that looks like the best place to extract the algorithms and put them into Similar, like here:

https://github.com/dtolnay/dissimilar/blob/master/src/lib.rs#L506

For my particular use case, the dissimilar implementation actually appears to work quite well.