Remove server side document selectors #3074
Merged
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
I finally understood the mysterious requests we were receiving from URIs we didn't care about or the duplicate requests thanks to microsoft/vscode-languageserver-node#1487 (comment).
We were overriding the document selectors we define in the client in the server, with a much more simplistic approach. In the client, we take steps to ensure that we're handling only certain schemes with specific patterns and not duplicating client handling for the
untitled
scheme.All of that configuration was lost for many requests because the server was simply broadcasting the document selector as
{ language: "ruby" }
, which is not scoped to any scheme or pattern.This results in every language server running in the current VS Code window advertise that they handle any Ruby file, which is why we kept receiving duplicate requests and why we kept receiving requests for schemes we are not interested in handling - like the
vscode-chat-code-block://
scheme.Implementation
Since our document selector logic is so complex and requires knowledge of default gem paths, bundled gem paths, workspace paths and so on, we should not override it from the server. Trying to implement the same document selector logic on both ends would probably lead to unnecessary headache.
All of our requests already specify in
server.rb
if they need to return early for a certain document type, so there's no risk of receiving undesired requests that we don't know how to handle.Considering that, I just set all document selectors in requests to
nil
, which makes the editor prefer the one configured by the client.