Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
21.04k stars 345 forks source link

Newlines in strings breaks display #632

Open NickNick opened 9 months ago

NickNick commented 9 months ago

Thanks for reporting a bug! Please include all of the following:

(1) A description of the issue. A screenshot is often helpful too.

Here are two screenshots. The first is my attempt to reproduce the issue, but it shows the perfect diff. I love it! The second one shows the diff in the real project, and as becomes clear by comparing the two screenshots, the diff is projected one line below the actual diff. This is pretty confusing.

Screenshot 2024-01-30 at 09 30 38 Screenshot 2024-01-30 at 09 30 59

(2) A copy of what you're diffing. If you're diffing files, include the before and after files. If you're using difftastic with a VCS repository (e.g. git), include the URL and commit hash.

I can't share the whole document, but I would like to help with making a small repro. I am not sure where to start though.

(3) The version of difftastic you're using (see difft --version) and your operating system.

Difftastic 0.54.0 (built with rustc 1.75.0) on macos.

Wilfred commented 9 months ago

Yep, that definitely looks like a bug!

Your attempt to reproduce isn't actually using the XML diff, note that it says Text. Try naming your sample files to something.xml so difftastic knows they're XML, and see if you can reproduce that way?

NickNick commented 9 months ago

Thanks for the quick response! Changing the extensions to XML manages to reproduce it. Here is the smallest one I could make. I would upload the files, but github does not support that, so here are the files inline (old, then new).

<p>
The potato
The bananas
</p>
<p>
The potatoes
The bananas
</p>

Diff

image