-
Notifications
You must be signed in to change notification settings - Fork 182
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
handle editor.action.rename
command for interoperability with VSCode
#2249
Conversation
I will try my best to review this till Friday (if not then next week) But +1 for the idea. Unfortunately it is better to handle vs code specific commands in lsp rather than lsp plugins to avoid repetition. It would be better if that was at least part of the LSP spec, but I don't mind it. |
@@ -1561,7 +1592,9 @@ def execute_command(self, command: ExecuteCommandParams, progress: bool) -> Prom | |||
) | |||
) | |||
|
|||
def run_code_action_async(self, code_action: Union[Command, CodeAction], progress: bool) -> Promise: | |||
def run_code_action_async( | |||
self, code_action: Union[Command, CodeAction], progress: bool, source_view: Optional[sublime.View] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just call source_view
-> view
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LSP-jdtls and metals use execute_command
but this change is backwards compatible, so all good.
How could I test this with volar?
I wasn't able to find a code action that will do editor.action.rename
,
could you give me a hint?
I tried a couple of refactoring code actions with volar but none of them seem to trigger the editor.action.rename
.
You can try selecting the value of the Screen.Recording.2023-05-15.at.23.53.55.movNote that I found some of those code actions pretty broken but it's the same in VSCode so I would blame Volar not handling those too well. (Those code actions come from TS but run in this weird Vue context so probably are not always handled correctly) |
Yeah, I tried the "Extract to constant in enclosing scope", and I see that the text edits are applied, but I do not see a
I assumed that code action to have such command on it, and right after the text edits were applied, I expected to see a rename request being triggered. But that is not case... I will try tomorrow. :) |
You might try with sublimelsp/LSP-volar#174. |
I still do not get the command "editor.action.rename" for code actions. |
It reproduces here in https://github.com/rchl/nuxt-2-playground in Screen.Recording.2023-05-16.at.21.41.02.mov |
Yeah, it basically doesn't work in Vue which I would guess is due to Volar just not supporting those cases. We can wait with this and see if there are any actually working cases in Volar. |
I would wait only because none of the existing LSP-* plugins don't intercept any of the following commands: Volar uses it, but it is broken for now. |
Added support for the
editor.action.rename
command since Volar and possibly other servers use it.I had to move handling of VSCode-specific commands from
LspExecuteCommand
toSession.execute_command
because when triggering a code action, the code doesn't go through the Text Command.Since those VSCode-specific commands kinda required
View
, I'm passing it though toexecute_command
so that I don't have to use hacky way of "get any or active view for session".Volar returns code actions like: