Skip to content

A file connected for a request without an editor stays connected after the file is deleted #2335

Done

Description

@lagergren

Version: 0.30.1 (also main at 2ac45b7).

What happens

LanguageServiceAccessor.getLanguageServers(file, …) connects the file to each matched language server (didOpen)
whether or not an editor has it open. LSPDebugVariablePositionProvider.getVariableLookups does this for a suspended
frame's file, also on each workspace/inlineValue/refresh. A document connected that way stays connected for good:

  • when its file is deleted, no textDocument/didClose is sent;
  • getOpenedDocuments() keeps an OpenedDocument whose VirtualFile is no longer valid, and that document's
    diagnostics keep being pulled;
  • when a file is created again at the same URL, connectDocument reuses the stale document
    (getConnectedSynchronizer), so the server keeps the deleted file's text.

Steps

  1. Debug a program with a language server that supports textDocument/inlineValue, and stop in A.x.
  2. Close A.x's editor, so no editor has the file.
  3. Have the server send workspace/inlineValue/refresh. LSP4IJ sends textDocument/didOpen for A.x, with no editor.
  4. Delete A.x.

Expected: textDocument/didClose for A.x once its file is deleted (and, ideally, once no request needs a document
that has no editor).

Actual: no didClose. A.x stays in getOpenedDocuments() with an invalid file, its diagnostics keep being
pulled, and a new A.x at the same URL is served the deleted text.

Where we saw it: the Ecstasy language server's IntelliJ playbook (xtclang/xvm). A debug case stopped in a file,
its cleanup deleted the file, and the document stayed connected. Our rename's check, which compares the documents a
rename saw with those open when it applies, then counted the invalid file as a change and refused every later rename
and move. We now tolerate a file that was already deleted before the request; that tolerance can go once a deleted
file's document is disconnected.

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

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions