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

Declare workspaceFolders support in server capabilities #4666

Merged
merged 4 commits into from
Mar 1, 2023
Merged

Declare workspaceFolders support in server capabilities #4666

merged 4 commits into from
Mar 1, 2023

Conversation

the-mikedavis
Copy link
Contributor

The vscode-languageserver-node dependency will attempt dynamic capability registration for workspace folder change notifications if this workspace.workspaceFolders.changeNotifications is not set in the InitializeResult. That is problematic for clients that don't support dynamic capability registration: if we send a JSONRPC error, the server will exit because of the rejected promise.

The server has support for workspace folders and requests and uses change notifications as far as I can see, so I believe it's more correct to declare support for these up-front anyways.

This is the recommended way to avoid dynamic capability registration for this case with vscode-languageserver-node: (comment)

Fixes #2690
Fixes #1302
This and a change within Helix (helix-editor/helix#6058) will resolve issues we started seeing in 1.1.293 (#4602)
See also microsoft/vscode-languageserver-node@5bc82ac
Revelant part of the spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders
Here is where the change notification handler is set up in pyright and what triggers dynamic capability registration within vscode-languageserver-node.

The `vscode-languageserver-node` dependency will attempt dynamic
capability registration for workspace folder change notifications
if this `workspace.workspaceFolders.changeNotifications` is not set
in the `InitializeResult`. That is problematic for clients that don't
support dynamic capability registration: if we send a JSONRPC error,
the server will exit because of the rejected promise.

The server has support for workspace folders and requests and uses
change notifications as far as I can see, so I believe it's more
correct to declare support for these up-front anyways.
@erictraut
Copy link
Collaborator

Thanks for the contribution. Looks good to me.

@heejaechang, I'm adding you as a reviewer also.

@erictraut
Copy link
Collaborator

@heejaechang, any thoughts on this PR? If I don't hear from you in the next day, I'll assume it's OK and merge it.

@heejaechang
Copy link
Collaborator

I think it is right thing to do. we already listen for workspace folder change event and support workspace folders.

@heejaechang
Copy link
Collaborator

It looks like when we register for workspace folder change event, LSP library automatically send registerCapabilities for workspace folder change support. and that's why it worked fine for vscode and we didn't notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants