Skip to content

Inconsistent identifier highlighting with 2025.2 #1300

Closed

Description

@SCWells72

This seems to be a recent regression, but I noticed that when the caret is placed on an identifier in an LSP4IJ-managed document, identifier highlighting is applied in an inconsistent/unreliable manner. Here's an example:

Image

Hopefully that conveys the issue clearly where at first the identifier under the caret is highlighted properly, but as I click around, it stops working, though not completely. However, I no longer see textDocument/documentHighlight entries in the trace log as I click around, so that's probably a good lead on whatever is happening.

The example above is in TypeScript, but I see the same thing for other language servers as well, e.g., CSS.

Oh, and this is all with the latest published version, 0.16.1.

Let me know if I can provide any other details.

Activity

  1. angelozerr commented on Sep 26, 2025

    @angelozerr
    Contributor

    Have you the problem with IJ community?

    Have you the same problem with old IJ?

    Thats strange because I dont remember having doing some changes about highlight (but perhaps I am wrong:))

  2. SCWells72 commented on Sep 26, 2025

    @SCWells72
    ContributorAuthor

    Have you the problem with IJ community?

    Yes, this is all in IntelliJ IDEA Community Edition since that doesn't have native JavaScript/TypeScript/CSS support and LSP4IJ is being used to provide support for those languages there.

    Have you the same problem with old IJ?

    I'm not sure. I don't have older versions of Community Edition installed, only Ultimate Edition for verification and testing of my own plugin against older versions. I noticed this a little back so my guess is that it's been happening for at least a few versions.

    Hopefully it should be pretty simple to reproduce based on the description and video I provided above, but let me know if not.

  3. angelozerr commented on Sep 26, 2025

    @angelozerr
    Contributor

    I cannot reproduce the issue tr

    Could you give me the content of the ts file that you are using in the demo?

  4. SCWells72 commented on Sep 26, 2025

    @SCWells72
    ContributorAuthor

    The one in the demo has some additional files behind it, but I reproduced it in a standalone project with no other dependencies. That project contains the following two files:

    Account.ts

    export interface Account {
        AccountNumber: string;
    }

    MyComponent.ts

    import {Account} from "./Account";
    
    export default class MyComponent {
        testAccountAccess() {
            let account: Account = { AccountNumber: "12345" };
            let accountNumber = account.AccountNumber;
        }
    }

    LSP4IJ 0.16.1 is the only installed third-party plugin:

    IntelliJ IDEA 2025.2.2 (Community Edition)
    Build #IC-252.26199.169, built on September 18, 2025
    Source revision: 7fd6c69de64ef
    Runtime version: 21.0.8+1-b1038.71 aarch64 (JCEF 122.1.9)
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    Toolkit: sun.awt.windows.WToolkit
    Windows 11.0
    GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
    Memory: 2048M
    Cores: 12
    Registry:
      ide.experimental.ui=true
      llm.show.ai.promotion.window.on.start=false
    Non-Bundled Plugins:
      com.redhat.devtools.lsp4ij (0.16.1)
    Kotlin: 252.26199.169-IJ
    

    Here's a video of that reproduction:

    Image

    As you can see, I had to click around a bit before it started happening, but once it does, it continues to do so until I close and reopen that editor tab (or perhaps even project window).

  5. angelozerr commented on Sep 27, 2025

    @angelozerr
    Contributor

    Could you test with 2025.1 please.

  6. angelozerr commented on Sep 27, 2025

    @angelozerr
    Contributor

    I have tried with 2025.2 with lsp4ij installed and I can reproduce the issue. Sometimes it doesnt send the highlight lsp request?

    I have tried with 2025.1 by launching lsp4ij (to debug it) and I cannot reproduce the issue?

    Unfortunately I cannot start lsp4ij with 2025.2 I have an error with couroutine agent and a classnotfoundexcetion.

    @sbouchet please help me :)

  7. added
    bug
    on Sep 27, 2025
  8. changed the title [-]Inconsistent identifier highlighting[/-] [+]Inconsistent identifier highlighting with 2025.2[/+] on Sep 30, 2025
  9. angelozerr commented on Sep 30, 2025

    @angelozerr
    Contributor

    @SCWells72 according my test, this issue comes from since 2025.2. After debugging quickly, IJ call just one time LSPHighlightUsagesHandlerFactory. IJ has changed something -(

  10. SCWells72 commented on Sep 30, 2025

    @SCWells72
    ContributorAuthor

    @SCWells72 according my test, this issue comes from since 2025.2. After debugging quickly, IJ call just one time LSPHighlightUsagesHandlerFactory. IJ has changed something -(

    I kind of expected it might be something like that as I've noticed that identifier highlighting is lagging in my plugin as well in the more recent versions. It does eventually happen, but it's like it's a deprioritized background action.

    I would recommend grabbing the stack trace by which LSPHighlightUsagesHandlerFactory is invoked -- specifically the core plugin SDK parts of that stack trace -- and demonstrating clearly that it's called more reliably in 2025.1 than in 2025.2, and logging a bug in YouTrack about this potential regression -- and minimally change in behavior -- in the newer IDE versions. I'll be curious to see what they say.

  11. angelozerr commented on Sep 30, 2025

    @angelozerr
    Contributor

    By debugging IJ it seems it caches highlight result for a given PsiElement.

    It means if you click on an offset which returns your lsp semantic psi element it consumes lsp request and it is working. If you select again this element there is no lsp request and it uses the cache.

    This cache seems evicted when you update the editor content.

    But if you click on an offset which is not an lsp semantic tokens it uses PsiFile which covers the all ranges and after that nothing is working.

    It seems highlights is working only with proper PsiFile which is unusable for lsp.

  12. angelozerr commented on Sep 30, 2025

    @angelozerr
    Contributor

    @SCWells72 according my test, this issue comes from since 2025.2. After debugging quickly, IJ call just one time LSPHighlightUsagesHandlerFactory. IJ has changed something -(

    I kind of expected it might be something like that as I've noticed that identifier highlighting is lagging in my plugin as well in the more recent versions. It does eventually happen, but it's like it's a deprioritized background action.

    I would recommend grabbing the stack trace by which LSPHighlightUsagesHandlerFactory is invoked -- specifically the core plugin SDK parts of that stack trace -- and demonstrating clearly that it's called more reliably in 2025.1 than in 2025.2, and logging a bug in YouTrack about this potential regression -- and minimally change in behavior -- in the newer IDE versions. I'll be curious to see what they say.

    Before doing that I would like to try to fix the issue. Ineed just to understand how this cache is working

  13. angelozerr commented on Sep 30, 2025

    @angelozerr
    Contributor

    @SCWells72 after debugging IJ 2025.2, the problem comes from https://github.com/JetBrains/intellij-community/blob/fafeca54382eac161c74c2b9f53bbb767182c5da/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlightingComputer.kt#L98 when you click on an offset which return a PsiElement which have the same range than PsiFile (ex : when a file is TextMate and it returns a LeafElement), after that higlighting is broken (because it updates the cache with the empty result for the PsiFile text range).

    BUT hopefully, IJ seems have fixed the issue (according the code and comment) JetBrains/intellij-community@e228f69#diff-89b4262e9397a94ab3f5746b323dbbc890185315916314e940ca4e266dc7f1bcR256

    If this fix is correct, LSP highlight will be broken with 2025.2 but should fixed in future version.

  14. angelozerr commented on Oct 9, 2025

    @angelozerr
    Contributor

    @SCWells72 I have tested with 2025.3 and it seems it is working again. Could you try it please.

  15. SCWells72 commented on Oct 9, 2025

    @SCWells72
    ContributorAuthor

    @SCWells72 I have tested with 2025.3 and it seems it is working again. Could you try it please.

    @angelozerr, yes, it does seem to work properly again in 2025.3 EAP. I wonder if they'll backport whatever fixes that to 2025.2.4 or similar.

  16. angelozerr commented on Oct 9, 2025

    @angelozerr
    Contributor

    Thats strange sometimes it is working and sometimes not.

    One of a usecase is when server is starting and you click on a method name. At this step lsp highlight return nothing. IJ cache the result and when you click again when server is started as it is cached lsp request is not called.

    For other usecase I need to debug IJ himself but no time for the moment to do that

  17. angelozerr commented on Apr 8, 2026

    @angelozerr
    Contributor

    @SCWells72 it seems IJ 2026.1 fixes the issue right?

  18. angelozerr commented on Apr 22, 2026

    @angelozerr
    Contributor

    I close the issue because it seems working with 2026.1. If it doesn't work please reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdocumentHighlight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions