Skip to content
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

Provide an optional response handler in LspExecuteCommand #1902

Closed
ayoub-benali opened this issue Nov 22, 2021 · 3 comments · Fixed by #2024
Closed

Provide an optional response handler in LspExecuteCommand #1902

ayoub-benali opened this issue Nov 22, 2021 · 3 comments · Fixed by #2024

Comments

@ayoub-benali
Copy link
Contributor

ayoub-benali commented Nov 22, 2021

Is your feature request related to a problem? Please describe.
I would like to extends LspExecuteCommand in order to send a workspace/executeCommand but LspExecuteCommand simply logs the response. In my case I have to open a file URI that is in the reponse.

Describe the solution you'd like
LspExecuteCommand should provide an optional response handler. When missing simply log the response as the case now. Otherwise delegate the response handling.

Describe alternatives you've considered
The current alternative is to copy LspExecuteCommand logic.

@rchl
Copy link
Member

rchl commented Nov 22, 2021

Sounds like an easy PR. Move

msg = "command {} completed".format(command_name)
if response:
msg += "with response: {}".format(response)
window = self.view.window()
if window:
window.status_message(msg)
to a new method on_result_async(self, response) that the plugin will be able to override.

@predragnikolic
Copy link
Member

There was this PR that added on_server_response_async #1992

    def on_server_response_async(self, method: str, response: Response) -> None:
        """
        Notifies about a response message that has been received from the language server.
        Only successful responses are passed to this method.
        :param    method:    The method of the request.
        :param    response:  The response object to the request. The response.result field can be modified by the
                             plugin, before it gets further handled by the LSP package.
        """
        pass

Will it suite your usecase?

@rchl rchl closed this as completed Aug 16, 2022
@rchl rchl reopened this Aug 16, 2022
@rchl
Copy link
Member

rchl commented Aug 16, 2022

Would be kinda weird and hard to follow a code that executes a command in one place but handles the result in a completely different place. So I think this simple change would still be better.

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 a pull request may close this issue.

3 participants