samg / diffy

Easy Diffing in Ruby
http://rubygems.org/gems/diffy
MIT License
1.26k stars 103 forks source link

Bug: Lines with dashes are dropped when different #77

Closed ninewise closed 5 years ago

ninewise commented 7 years ago

When a line on the left side of a diff starts with --, the line is dropped from the diff. When running puts Diffy::Diff.new("aa\n--\ncc\n", "aa\nbb\ncc\n") you get:

 aa
+bb
 cc

but you'd expect:

 aa
---
+bb
 cc

More examples:

puts Diffy::Diff.new("a a\n-- b\nc c", "a a\nb b\nc c") # fails
puts Diffy::Diff.new("a a\n- b\nc c", "a a\nb b\nc c") # works
puts Diffy::Diff.new("a\n-\nc", "a\nb\nc") # works
puts Diffy::Diff.new("a\n---\nc", "a\n----\nc") # fails

Diffy's been serving us really well otherwise, btw, so thanks for the great work!

samg commented 7 years ago

Looks like the issue is the regex at https://github.com/samg/diffy/blob/master/lib/diffy/diff.rb#L85. I'll see if I can get a fix in in the next few days.

bmesuere commented 7 years ago

Any progress on a fix?