difftastic
difftastic copied to clipboard
Rust attribute changes are not ideally associated
Using the indexmap repo, I tried the following command:
GIT_EXTERNAL_DIFF=difftastic git show --ext-diff 49d430808ced6d1824ec15d621acd6b0e8367c19
and got this output near the end:
Notice how the #[test]
attribute is interpreted, where the following one is considered to be an insertion, instead of the one that's on the new function. This kind of thing is very common with line-based diffs, although plain git show
actually does get this right!
Yeah, this is sometimes called a "slider", and difftastic isn't completely immune.
I have been thinking about trying to nudge the diff logic to avoid blank lines, but it might increase complexity. The best solution for Rust here is probably to improve the tree-sitter parser to include the attribute with the function definition.
I'm seeing the exact slider behavior described above, in Difftastic 0.31.0, in my codebase (redacting the test function body, private and probably not relevant):
However, it does get the above indexmap
example right:
Not sure what the difference is. Maybe these just fall on either side of some heuristic threshold?