GithubHelp home page GithubHelp logo

tdiff's People

Contributors

eproxus avatar odo avatar tomas-abrahamsson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tdiff's Issues

Using whitespace tweak to break ambiguity?

When comparing source code, it would be more natural (or convenient) to have:

[{eq,"A"},{ins," "},{eq,"/"},{ins," "},{eq,"B"},{del," "}] = tdiff:diff("A/B ", "A / B").
[{eq,"C("},{ins," "},{eq,"D"},{del," "}] = tdiff:diff("C(D ", "C( D").
[{eq,"E"},{ins," "},{eq,"+"},{del," "},{eq,"F"},{del," "}] = tdiff:diff("E+ F ", "E +F").

instead of the current diff output

[{eq,"A"},{ins," "},{eq,"/"},{del,"B"},{eq," "},{ins,"B"}] = tdiff:diff("A/B ", "A / B").
[{eq,"C("},{del,"D"},{eq," "},{ins,"D"}] = tdiff:diff("C(D ", "C( D").
[{eq,"E"},{del,"+"},{eq," "},{ins,"+"},{eq,"F"},{del," "}] = tdiff:diff("E+ F ", "E +F").

This somehow corresponds to giving less weight to whitespace changes when counting the 'edit cost'.
Since whitespace is lexically smaller than other text, it could be possible to favor whitespace changes without braking the code when no ambiguity exists.

Alternatively, it might be possible to favor the diff output which maximize the number of equal terms (also only if there is ambiguity).

Any idea where in the code to do this tweak?

Upload to Hex.pm

I'm publishing Unite which depends on tdiff to Hex.pm. It would be very helpful if tdiff also existed on Hex.pm. Would it be possible for you to upload it? Alternatively, I can also fork it and upload it if you approve of that.

diff_binaries does not seem to work as I expected

Here are a couple of test cases

t100() ->
    Old = "A cat ate my hat", 
    New = "A dog ate my shoe",
    P = tdiff:diff(Old, New),
    New = tdiff:patch(Old, P),
    yes.

t101() ->
    Old = <<"A cat ate my hat">>, 
    New = <<"A dog ate my shoe">>,
    P = tdiff:diff_binaries(Old, New),
    New = tdiff:patch(Old, P),
   yes.

This is what happens when I run them

   1> test_tdiff:t100().   
  yes
  2> test_tdiff:t101().
  ** exception error: no match of right hand side value ["A dog ate my shoe"]
      in function  test_tdiff:t101/0 (test_tdiff.erl, line 18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.