Skip to content

A document that no editor shows stays connected after the request that connected it #2341

Backlog

Description

@lagergren

Postponed: nothing is wrong with these documents, and no one has reported their cost. Found while fixing #2335 (#2340).

What happens

A request for a file that no editor shows connects the file for good: LanguageServiceAccessor.getLanguageServers(file, …) sends textDocument/didOpen, and only these disconnect it:

The exception is formatting. It connects through getLanguageServersForScope with a DocumentConnectionScope (#1707), which sends didClose once the scope ends, unless an editor has the file.

One way in is the inline values of a stopped debug session (LSPDebugVariablePositionProvider.getVariableLookups). It connects a file whose editor was closed while the session was stopped, at each stop and at each workspace/inlineValue/refresh.

Effects

The text stays right, since LSP4IJ keeps sending the changes of the document. But while the file exists:

  • the language server keeps the file open, and may analyze it as an open file;
  • LSP4IJ keeps pulling its diagnostics;
  • a language server whose only documents are such files never stops when idle, since keepAlive() counts every connected document.

Options

  • Connect per request through a DocumentConnectionScope, as formatting does, feature by feature. For the inline values, that's a change in getVariableLookups.
  • A general policy: a document connected without an editor is closed after its request, or after a delay.

Either sends didOpen and didClose for each request for such a file, and a language server may analyze the file again at each didOpen. VS Code asks for inline values only for a document that an editor shows.

Activity

  1. added
    enhancement
    on Nov 28, 2026
  2. added this to the 0.30.3 milestone on Nov 30, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions