6 ms·
I don't understand why GitHub hasn't solved the issue of diffs starting with a '}' (or ')' or 'end'). Just slide the diff over while it starts with a closing to
by CodeIsTheEnd 5y ago
I don't understand why GitHub hasn't solved the issue of diffs starting with a '}' (or ')' or 'end'). Just slide the diff over while it starts with a closing token! I suppose it's an artifact of the diffing algorithm, but aren't there better diffing algorithms, even built-in within git?
This is by far the most obvious example of "git doesn't understand programming languages", but it also seems like the most straightforward to fix.
- nemetroid 5y agoGit supports a few different diff algorithms. GitHub only seems to support the standard Myers algorithm, though: https://github.com/isaacs/github/issues/455 https://github.com/isaacs/github/issues/455
- mynegation 5y agoIt is because diff is syntax agnostic. You might be able to get away with this hack in some cases but that complicates algorithm and will break in some other cases (how about nested brackets? Multiple brackets on one line?). Once you want to handle this properly you need syntax aware diff algorithm and some resources are linked in this discussion.