Skip to content

A reconnect queued for a moved document starts a language server that a stop switched off #1912

Closed

Description

@lagergren

A reconnect of a moved document that was queued before stopAndDisable() starts the language server again once it runs. The language server is then running while it is switched off.

How it happens

When a file whose document is connected is renamed or moved, LSPFileListener.onFileRenameAfter disconnects the document and calls reconnectMovedDocument(VirtualFile), which connects it again on the EDT, after the write action. For a language server without instances, that ends in reconnectMovedDocument(LanguageServerWrapper, VirtualFile), which calls connect() without checking isEnabled(). connectDocument then calls start(), which doesn't check it either. Only the path of an instance checks instance.isEnabled() first.

So a stop between the move and the queued reconnect doesn't keep the language server off. A test on main renames an open file whose document is connected, calls stopAndDisable() before the EDT runs the queued reconnect, and then lets it run: isEnabled() is false, but isActive() is true and the file is synchronized again.

#1911 adds two more ways to that reconnect: a document that the move of its file missed, and an open file whose connection dropped because the file moved.

Possible fix

Check isEnabled() in reconnectMovedDocument(LanguageServerWrapper, VirtualFile), which every reconnect goes through:

        if (!isOpenDocument(languageServer, file) || !languageServer.isEnabled()) {

With it, the test passes, and so do the tests of moves, renames, file operations and instances.

Found in the review of #1911.

Activity

  1. lagergren commented on Nov 9, 2026

    @lagergren
    CollaboratorAuthor

    Fixed by #1911 (766184d), merged as 2253ca0: the reconnection of a moved document checks isEnabled() before it connects, now for a language server without instances too, so a stop between a move and its queued reconnection keeps the language server off. #1911's description names it with the same "Fixes" as #1904, which GitHub takes for #1904 only.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions