difftastic icon indicating copy to clipboard operation
difftastic copied to clipboard

JSON output doesn't contain optional `MatchKind` data

Open nimrodkor opened this issue 11 months ago • 0 comments

Hello again!

I ran into an gap when trying to diff, example for simplicity:

// Original
println!("Hello, world!");

// New
println!("Hello, dear world!");

The terminal output knows to mark dear specifically because it knows it is a NovelWord vs the rest of the line, which is NovelLinePart. However, the JSON output strips that away and leaves only the highlight (i.e. String). There are at least 2 ways about this, would love to contribute. Options I thought about:

  1. Drop NovelLinePart from the changes list as it is not a real change as far as I can tell. If we get NovelLinePart it means the myers_diff found the string in both sides, right?
  2. Add the MatchKind itself, as an str, to the JSON output. Something like this:
    {
        "changes": [
            ...
            {"start":17,"end":21,"content":"dear","highlight":"string","highlight_type":"NovelWord"}, 
            {"start":22,"end":27,"content":"world","highlight":"string","highlight_type":"NovelLinePart"}
        ]
    }
    

WDYT @Wilfred ? I'll be happy to contribute this

nimrodkor avatar Mar 13 '24 14:03 nimrodkor