Closed MA-Maddin closed 7 years ago
They aren't broken. It's just how the diff algorithm works. We never implemented heuristics for it. @alexandrudima can provide more details.
@MA-Maddin Text diff algorithms in general, and also the one in VSCode, are implemented using an algorithm known as LCS (Longest Common Substring). This means that the diff algorithm will try to identify the most amount of matching lines and then will map the non-matched lines to either deletes or inserts.
Sometimes, there are multiple LCSs between two list of lines (between two files). Some of them are more human pleasing, or reflect the actual inserted lines, some do not.
This is, unfortunately, the state-of-the-art when using an LCS diff algorithm. Better algorithms include doing a diff on the AST, but we don't have that. i.e. we are similar to git in this respect.
I don't know how it is called, but the green and blue "code changes highlighting" on the left seems broken in some situations.
I already have saved the file multiple times, restarted VS Code, restarted PC.
See this video: https://www.youtube.com/watch?v=AQuVR_SeUB4
Maybe related with #27715
Steps to Reproduce: I don't yet know how to reproduce it.