Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git diff highlighting is broken sometimes #28249

Closed
MA-Maddin opened this issue Jun 8, 2017 · 2 comments
Closed

Git diff highlighting is broken sometimes #28249

MA-Maddin opened this issue Jun 8, 2017 · 2 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@MA-Maddin
Copy link

MA-Maddin commented Jun 8, 2017

  • VSCode Version: Code 1.13.0 (376c52b, 2017-06-08T16:43:13.058Z)
  • OS Version: Windows_NT ia32 10.0.15063
  • Extensions:
Extension Author Version
file-icons file-icons 1.0.3
Angular2 johnpapa 2.2.3
java redhat 0.2.0

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.

@joaomoreno
Copy link
Member

They aren't broken. It's just how the diff algorithm works. We never implemented heuristics for it. @alexandrudima can provide more details.

@alexdima
Copy link
Member

alexdima commented Oct 2, 2017

@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.

@alexdima alexdima closed this as completed Oct 2, 2017
@alexdima alexdima added the *as-designed Described behavior is as designed label Oct 2, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

3 participants