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

Problem messages can get offset by frequent changes to the document #1633

Closed
0dinD opened this issue Sep 22, 2020 · 5 comments
Closed

Problem messages can get offset by frequent changes to the document #1633

0dinD opened this issue Sep 22, 2020 · 5 comments

Comments

@0dinD
Copy link
Contributor

0dinD commented Sep 22, 2020

When editing a Java file with problems in it, the underlines (reported problem positions) can sometimes become offset. Usually, this fixes itself after a second or so of delay, but in some rare cases the problem underline gets stuck in the wrong position until further changes are made to the document.

Environment
  • Visual Studio Code version: 1.49.1
  • Java extension version: 0.67.0
Steps To Reproduce
  1. Open a Java class with problems in it (unused variable warnings, for example).
  2. Make some changes in quick succession.
  3. You should see the error messages jumping around and getting offset to incorrect positions.
  4. In some rare cases, the error messages get stuck on the wrong location until a new character is typed.
Current Result

problem-offset-bug-1
problem-offset-bug-2

Expected Result

The error messages (underlines) should always appear on the correct positions, and never get stuck on the wrong ones, like in the screenshot above.

Additional Informations

As you can see in the screenshots above, not only are the error messages offset, the semantic tokens are also offset in the exact same way (see #1597). I've submitted two PRs (#1632, eclipse-jdtls/eclipse.jdt.ls#1552) to fix the semantic highlighting issue, but this issue with problem messages still persists since I only changed the semantic highlighting implementation. From what I can tell in the screenshots above, the two issues seem highly related, so a fix for this PR can probably be made by looking at how I fixed #1597.

This is how the semantic tokens look with #1632 and eclipse-jdtls/eclipse.jdt.ls#1552 applied, I would expect the problem underlines to behave in the same way:
problem-offset-bug-3

@0dinD
Copy link
Contributor Author

0dinD commented Sep 24, 2020

If anyone wants a more detailed showcase on how to reproduce the issue, see my comment here. Those instructions apply to this issue as well.

@0dinD
Copy link
Contributor Author

0dinD commented Sep 30, 2020

Here's another example, which occurred when applying a fix from the integrated merge conflict resolver in VS Code. The errors were caused by the conflict markers, but when the document was changed with the conflict resolver, the errors became offset to the wrong location, and also didn't go away until the document was changed again. I'm guessing the cause is that the conflict resolver is making multiple document edits in quick succession when applying the fix.

offset-bug-error

This is what I mean by "conflict resolver". The fix I applied was "Accept Incoming Change".

conflict-resolver

@0dinD
Copy link
Contributor Author

0dinD commented Oct 22, 2021

I've just discovered the root cause of this issue, see eclipse-jdtls/eclipse.jdt.ls#1920 for details and how to reproduce this issue with 100% accuracy.

@0dinD
Copy link
Contributor Author

0dinD commented Oct 22, 2021

Now that we know the cause for the issue I also realized that if you use files.autoSave, the issue will reproduce even more often, so it might be a more common issue than I had previously thought. Personally I don't like auto-save, but some prefer it.

@0dinD
Copy link
Contributor Author

0dinD commented Nov 24, 2021

Seeing as eclipse-jdtls/eclipse.jdt.ls#1930 was merged (and fixes this issue), this issue can now be closed.

@0dinD 0dinD closed this as completed Nov 24, 2021
@rgrunber rgrunber added this to the Late November milestone Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants