Skip to content

fix: Send didRenameFiles notifications to any language server that su… - #1223

Merged
angelozerr merged 2 commits into
redhat-developer:mainfrom
sergeysavchuk:1216_send_didRenameFiles_for_all_servers
Aug 21, 2025
Merged

angelozerr merged 2 commits into
redhat-developer:mainfrom
sergeysavchuk:1216_send_didRenameFiles_for_all_servers

Conversation

@sergeysavchuk

Copy link
Copy Markdown
Contributor

Send didRenameFiles notifications to any language server that supports it, regardless of willRenameFiles support or execution status. Previously, didRenameFiles was only sent to servers that supported and successfully executed willRenameFiles.

Fixes #1216

@angelozerr

Copy link
Copy Markdown
Contributor

@bzoracler is there any chance that you try this PR to check that it doesn't break the rename files support

}

context.renameFilesParams()
.forEach((ls, params) -> ls.getWorkspaceService().didRenameFiles(params));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep serverWrapper.sendNotification which uses a proper Thread pooling to send notification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu, fixed, please review

@angelozerr angelozerr Aug 20, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Before merging this PR I would like that @bzoracler can test it but ihe is blocked with #1224 that I ,am trying to fix it.

More as rename files is not trivial Ithink we should have tests for that.

If you have time ro work on it it would be fantastic but I know it is not a trivial issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergeysavchuk I did a fix and merge the PR, could you rebase your PR from main please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @bzoracler please test this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelozerr can you trigger the plugin build workflows please

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergeysavchuk do you think you could work on tests? If yes, we can doo that in a separate PR.

@bzoracler

Copy link
Copy Markdown
Contributor

@angelozerr This may take a while - last LSP4IJ version that worked properly with my server was v12.0. After v12.0, When I start PyCharm, the only textDocument/did* notifications received are those for windows that were re-opened in the previous PyCharm session at the very start, and these can only be textDocument/didClosed; re-opening these existing windows, or opening new windows, no longer shows any did* messages.

@angelozerr

Copy link
Copy Markdown
Contributor

@angelozerr This may take a while - last LSP4IJ version that worked properly with my server was v12.0. After v12.0, When I start PyCharm, the only textDocument/did* notifications received are those for windows that were re-opened in the previous PyCharm session at the very start, and these can only be textDocument/didClosed; re-opening these existing windows, or opening new windows, no longer shows any did* messages.

If I understand correctly, after v12.0 LSP4IJ is unusable for you, you have none didOpen, didClose (I mean just open and close file inside IntelliJ without renaming file).

Is that?

@angelozerr

Copy link
Copy Markdown
Contributor

@bzoracler could you tell me which language server are you using please.

@bzoracler

bzoracler commented Aug 20, 2025 •

Copy link
Copy Markdown
Contributor

@angelozerr This may take a while - last LSP4IJ version that worked properly with my server was v12.0. After v12.0, When I start PyCharm, the only textDocument/did* notifications received are those for windows that were re-opened in the previous PyCharm session at the very start, and these can only be textDocument/didClosed; re-opening these existing windows, or opening new windows, no longer shows any did* messages.

If I understand correctly, after v12.0 LSP4IJ is unusable for you, you have none didOpen, didClose (I mean just open and close file inside IntelliJ without renaming file).

Is that?

Almost.

After v12.0, once I start PyCharm, didOpen only triggers on windows that are automatically re-opened. By automatically-re-opened, I mean that PyCharm automatically re-opens windows that you didn't close in the previous session.

The trace is this:

[Trace - 12:30:23] Sending request 'initialize - (1)'.
[Trace - 12:30:23] Received request 'workspace/configuration - (48933df8-f45e-497b-8152-5b0a00c1818d)'.
[Trace - 12:30:23] Sending response 'workspace/configuration - (48933df8-f45e-497b-8152-5b0a00c1818d)'. Processing request took 0ms
[Trace - 12:30:23] Received response 'initialize - (1)' in 0ms.
[Trace - 12:30:23] Sending notification 'initialized'
[Trace - 12:30:23] Sending notification 'workspace/didChangeConfiguration'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Sending notification 'textDocument/didOpen'
[Trace - 12:30:23] Received notification 'window/logMessage'
[Trace - 12:30:23] Received request 'workspace/configuration - (7afa56fd-2ffb-4559-a139-c023221053ba)'.
[Trace - 12:30:23] Sending response 'workspace/configuration - (7afa56fd-2ffb-4559-a139-c023221053ba)'. Processing request took 0ms

After this, there are no more textDocument/didOpens sent, even after I open a new window in the UI. didClose only works on the textDocument/didOpen that you see in the trace, since there are no more didOpen events.

I'll try to produce a minimum working example, the server itself is not published and is quite complicated to set up. I'm trying to see whether I assumed something on my end that broke when LSP4IJ updated.

@bzoracler

Copy link
Copy Markdown
Contributor

@angelozerr see minimal reproduction at #1224

Siarhei added 2 commits August 21, 2025 10:14
@sergeysavchuk
sergeysavchuk force-pushed the 1216_send_didRenameFiles_for_all_servers branch from 1b8c320 to 8462772 Compare August 21, 2025 07:15
@angelozerr

Copy link
Copy Markdown
Contributor

@sergeysavchuk I have seen in a comment that you have tried clojure-lsp, it is very nice.

It would be very nice if you could test with other language server like TypeScript, Go, Clangd (don't remember which servers supports rename files). With LSP4IJ it should be super easy since it provide LSP template for that and even installer.

For instance you need just to create a test.ts file or test.c file (test.go but you will need to install Go runtime before) and you should see an editor notification on the top of the editor which prompote the installation of the language server. If you click on it it will open the New language server dialog and you will just need to click on OK. Installation should be done automaticly.

@bzoracler

Copy link
Copy Markdown
Contributor

@angelozerr I just tested this, and the changes don't negatively affect my language server (which currently relies solely on renaming triggering didClose followed by didOpen), so I'm good with this PR.

@angelozerr

Copy link
Copy Markdown
Contributor

@angelozerr I just tested this, and the changes don't negatively affect my language server (which currently relies solely on renaming triggering didClose followed by didOpen), so I'm good with this PR.

Thanks for your feedback!

I need to find time to test it with other language servers. @sergeysavchuk if you have time to do that it would be nice otherwise I need to find time to do that in order to merge the PR.

@sergeysavchuk

Copy link
Copy Markdown
Contributor Author

@angelozerr I’ll try to test it today, but it would be better if you could also test since I still need to get familiar with other language servers.

@angelozerr

Copy link
Copy Markdown
Contributor

@angelozerr I’ll try to test it today, but it would be better if you could also test since I still need to get familiar with other language servers.

Yes sure!

@angelozerr

Copy link
Copy Markdown
Contributor

I have tested with TypeScript LS and Clojure LSP and it seems working pretty well.

Your PR breaks nothings, Thanks!

For tests I will try to write something.

@angelozerr
angelozerr merged commit 622bd06 into redhat-developer:main Aug 21, 2025
@sergeysavchuk

Copy link
Copy Markdown
Contributor Author

@angelozerr Thanks a lot for such quick feedback and for testing.
I also tested it with the Clojure LS — it implements both workspace/willRenameFiles and workspace/didRenameFiles, and everything works correctly. See the recording:

clojure_lsp_didRenameFiles.mov

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.

‘workspace/didRenameFiles’ is not sent if workspace/willRenameFiles is not supported by language server

3 participants