Skip to content

LSP inlay hint request blocks the EDT #835

Closed

Description

@FalsePattern

The LSPInlayHintsProvider.doCollect method blocks inside a read action while waiting for the LSP to respond, and in the case of that large file, the LSP can take a long time to complete, which causes IDE stutter every time inlay hints are refreshed (every few seconds when typing)
image

I've found a dirty workaround for this locally by always putting the future into the pendingFutures if it's not finished, and relying on the caching behaviour of the LSPInlayHintsSupport to provide the same future once the refreshEditorFeatureWhenAllDone triggers another inlay hint pass. This fixes the EDT freeze caused by the waitUntilDone call.
image

As a proper fix, we could add a boolean waitUntilDoneOrTimeout(future, psiFile, int timeoutMillis, List<CompletableFuture<?>> pendingFutures) method to CompletableFutures so that inlay hints that complete fast (<50ms or similar) get done synchronously without this extra async step, but ones that take longer will get the async route.

Activity

  1. added a commit that references this issue on Feb 20, 2025
    a0546c3
  2. added this to the 0.11.0 milestone on Feb 20, 2025
  3. self-assigned this
    on Feb 20, 2025
  4. added a commit that references this issue on Feb 20, 2025
    aff50a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions