Skip to content

Add better documentation on how clients should handle file renames #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kered13 opened this issue Feb 17, 2021 · 3 comments
Closed

Add better documentation on how clients should handle file renames #1203

Kered13 opened this issue Feb 17, 2021 · 3 comments
Milestone

Comments

@Kered13
Copy link

Kered13 commented Feb 17, 2021

I am in the process of implementing an LSP client, but reading the spec I cannot figure out how I should handle file renames.

  • There are the workspace/willRenameFiles and workspace/didRenameFiles methods, but servers are not required to support them.
  • The other logical option seems to be to issue a textDocument/didClose followed by a textDocument/didOpen with the new file name.
  • If a server does support the workspace operations, should didClose and didOpen still be sent?
  • If so, then should they be sent before or after willRenameFiles and didRenameFiles?
@dbaeumer
Copy link
Member

Good point. The recommended way on a file rename is to sent a close with the old file and a open with the new file.

@dbaeumer dbaeumer added this to the 3.17 milestone Feb 17, 2021
@DanTup
Copy link
Contributor

DanTup commented Jul 7, 2021

The recommended way on a file rename is to sent a close with the old file and a open with the new file.

Slightly related to #1263 - what about if the rename is only changing case?

Right now, VS code does not send a Close/Open in this case for macOS or Windows (regardless of whether the filesystem is actually case-sensitive or not). However it does send rename events (but continues to use the old casing for everything going forwards). This seems inconsistent and makes it difficult for servers to handle these types of renames.

@dbaeumer
Copy link
Member

dbaeumer commented Nov 5, 2021

I personally think that using whatever name the system started to use on case insensitive file systems is the right thing to do. There is actually no guarantee that the initial name had the casing as stored on disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants