Skip to content

A document can miss the move of its file while its connection is in progress #1904

Closed

Description

@lagergren

Follow-up to #1891, which closed the race between a move and a connection that registers the document of the moved file: the move now checks and disconnects the document in one step under documentsLock, as the connection checks the place of its file and registers the document. Three cases stay open, because the listener of the move doesn't see them, as @d-biehl described in the review of #1891:

  1. A language server without file operations. getSupportedEvents keeps the move of a file only if the file is open as prepareChange runs. A document registered after that check, and before the move, gets no onFileRenameAfter, so it stays connected at its earlier place. (CodeRabbit's thread)
  2. A moved directory. It takes its documents along in beforeVfsChange, before the move, where the check of a connection in progress still sees the earlier place, so the connection registers the document there.
  3. A dropped connection. A connection whose file moved since it was asked for doesn't register the document, and the move has no document to take along, so the open file gets no didOpen, and no language features from that server, until another request connects it. (CodeRabbit's thread)

None of them is new with #1891: the first two were possible before it, and in the third, the connection used to open the file at its earlier place instead.

Possible direction

After a move, the listener could also take along every document whose file has another URI now, and connect the open files whose place changed. That needs an applier for every batch with a move or rename, whatever getSupportedEvents keeps, so it gives back some of what the filter of #1884 saves.

@d-biehl, you offered to take these on in #1891; this issue is for that PR.

Activity

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