Handle responses for show window request and delegate to add-ons #2803
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Add-ons won't have a lot of flexibility when it comes to UI elements since the LSP specification doesn't prescribe that. However, we can still allow for a certain degree of interactions by delegating responses of the
window/showMessageRequest
request.This request made by the server allows LSPs to show a dialog with buttons to the user. The response includes which button was clicked and any other attributes (as long as the client supports additional properties).
We can use this to allow for more interactivity for add-ons. The current use case we will use this for is letting the Rails add-on inform the user there's a pending migration with a button to run it.
Implementation
Started handling responses for
window/showMessageRequest
. We enforce the add-ons must provide their name as part of the original request in order to receive the response delegated appropriately.Also, started remembering if the client supports additional properties. Add-ons can only use this mechanism in such cases because otherwise they don't have the means to inform us of their name for delegation.
Automated Tests
Added a test.