Skip to content

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

@0dinD

Description

@0dinD

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions