Skip to content

The move of a document creates the instance of its new place before asking its client features #1922

Closed

Description

@lagergren

A follow-up of the review of #1918 (comment), filed so that it didn't hold up that PR, which is merged as 176640b.

For a definition with several instances, the move of a document creates the instance of the new place of its file (LanguageServiceAccessor.getOrCreateInstanceOf) before LSPFileListener.reconnectMovedDocument(languageServer, file) asks its client features whether they take the file (isEnabled(file)). If they leave out the file there, the new instance stays without a document. Nothing removes an instance before its definition is removed or the project closes, so it stays listed in the Language Servers view. A request does the same, as it filters by isEnabled(file) after it creates the instances, but the move otherwise takes care not to create an instance for a place where it doesn't connect the file.

The check also runs on the EDT, where a request asks it on a pool thread. The default only reads the installation status without waiting, but an integrator's LSPClientFeatures.isEnabled(VirtualFile) isn't documented as safe for the EDT.

The question from the review: could the read action of the move ask it, next to isFileMappedToServer, of the client features of the language server that the document leaves? They come from the same definition, so that would check it before an instance is created, and off the EDT. Or can the client features of the new instance answer differently?

@d-biehl, if you don't think this is relevant, please close it.

Activity

  1. d-biehl commented on Nov 10, 2026

    @d-biehl
    Contributor

    Thanks for merging #1918, and for filing this. I'm at a conference until Thursday, so I can't look into it before Friday. If you'd like to fix it in the meantime, please go ahead.

    One thing from a first look: each instance has its own client features, and an integrator's isEnabled(file) can read the instance root through getServerWrapper(). So the client features of the instance that the document leaves may answer differently for its new place than those of the new instance. Otherwise I'll come back to it on Friday.

  2. lagergren commented on Nov 10, 2026

    @lagergren
    CollaboratorAuthor

    @d-biehl Thanks, and your point settled it: the client features of the instance that the document leaves can't answer for its new place. #1932 creates the instance of the new place only if its own client features take the file, and disposes it otherwise, as a request does with an instance that its filter doesn't accept. A test pins that the client features of the new instance decide.

    It leaves out the rest of what I asked here: the move still asks isEnabled(file) on the EDT, as before, and a request can still leave an instance without a document the same way, which #1932 describes. Comments on Friday are welcome, and enjoy the conference.

  3. added a commit that references this issue on Nov 11, 2026
    88a396d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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