Skip to content

Fix willRename behavior#2494

Open
afonsocarlos wants to merge 1 commit intophpactor:masterfrom
afonsocarlos:master
Open

Fix willRename behavior#2494
afonsocarlos wants to merge 1 commit intophpactor:masterfrom
afonsocarlos:master

Conversation

@afonsocarlos
Copy link

Rename only the original reference as described in WillRenameFiles LSP specifications

@dantleech
Copy link
Collaborator

dantleech commented Jan 7, 2024

can you describe the problem this fixes? what is the bug?

@afonsocarlos
Copy link
Author

Of course, my bad 😅

If you rename a file from within a neovim plugin that supports willRename LSP integration this neovim plugin will request the LSP renaming BEFORE it actually renames the file. Therefore, the TextDocumentLocator can't find any reference to the new file (as it still doesn't exist) and throws an error "Text Document not found".
According to the LSP specifications, we should send a response with the WorkspaceEdits which will be applied to workspace before the files are renamed, so it would make sense to find references for the class references before the rename.

By the way, I tested the rename feature with both nvim-lsp-file-operations and oil.nvim plugins and both broke with the same error from phpactor lsp server

@afonsocarlos
Copy link
Author

Have the issue and the solution become clear?

@przepompownia
Copy link
Contributor

I didn't see this PR till now and fixed it independently in #2531 along with adding missing response part.

Rename only the original reference as described in WillRenameFiles LSP
specifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants