samg / diffy

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

Lines different only by newline character don't come up as different in HTML mode only #38

Closed JasonBarnabe closed 10 years ago

JasonBarnabe commented 10 years ago

Diffy 3.0.2, Ruby 2.0.0.

2.0.0p247 :014 > Diffy::Diff.new("one\ntwo\nthree\n", "one\r\ntwo\r\nthree\r\n").to_s
 => "-one\n-two\n-three\n+one\r\n+two\r\n+three\r\n" 
2.0.0p247 :015 > Diffy::Diff.new("one\ntwo\nthree\n", "one\r\ntwo\r\nthree\r\n").to_s(:html_simple)
 => "<div class=\"diff\">\n  <ul>\n    <li class=\"del\"><del>one</del></li>\n    <li class=\"del\"><del>two</del></li>\n    <li class=\"del\"><del>three</del></li>\n    <li class=\"ins\"><ins>one</ins></li>\n    <li class=\"ins\"><ins>two</ins></li>\n    <li class=\"ins\"><ins>three</ins></li>\n  </ul>\n</div>\n" 
2.0.0p247 :016 > Diffy::Diff.new("one\ntwo\nthree\n", "one\r\ntwo\r\nthree\r\n").to_s(:html)
 => "<div class=\"diff\"></div>" 

Why would these not show up as different when using :html output only?

samg commented 10 years ago

Looks like a bug in the html formatter. That piece of code is fairly complex, due to the inline highlighting ability, and it looks like you've found an edge case it doesn't handle well.

I'm not sure when I'll be able to look into it, but I'll plan to investigate it at some point. Also feel free to submit a pull request with a failing test case (or a fix to the issue).

Thanks!

samg commented 10 years ago

This should be fixed now in version 3.0.4 of the gem. Thanks!