-
Notifications
You must be signed in to change notification settings - Fork 645
Avoid registering more than 1 formatting provider at a time #2446
Comments
@stamblerre For more context, please see microsoft/vscode#72315 and Can we have |
So the solution would be to always register formatting dynamically? How would this work for editors that don't support dynamic registration? |
For editors that don't support dynamic registration there is currently no way for them to unregister. All a server can do is to register things statically then. In general I think that a server should un-register a formatter if it gets disabled. |
So based on my understanding of microsoft/vscode#70314 (comment), we should check if the client supports dynamic registration, and if not statically register. Otherwise, we should dynamically register only. Is this correct? |
How would you identify whether the editor supports dynamic registration or not? |
@stamblerre yes, that is corrent. |
/cc |
Is there an upstream issue to track this? |
Filed golang/go#32989. |
@ramya-rao-a: With the fix in https://go-review.googlesource.com/c/tools/+/185244, I have started to see the duplicate formatting provider error. Is there something that needs to be changed on the VSCode-Go end before we can submit this change? |
Are you seeing the duplicate formatting problem even if you have opted into using the format feature from the language server i.e If so, then add a breakpoint at https://github.com/microsoft/vscode-go/blob/0.11.3/src/goMain.ts#L248 and see if vscode-go is registering its own formatter even when you have chosen to use the one from gopls Also, I believe |
The approach we tried for Based on the linked code, I would guess the VSCode-Go extension needs some additional logic to de-register the default formatting provider if the language server's formatting provider is dynamically registered. In this instance, it registers both providers because the language server sends back |
The other question I have is how can we handle the case when |
@stamblerre Edit: The Go extension registers its provider as it sees My settings:
And I have updated to the latest |
@ramya-rao-a Can you try to use this patch https://go-review.googlesource.com/c/tools/+/185244/5/internal/lsp/general.go to see if the behavior is what you'd expect? |
Apologies, the assessment in my earlier comment was wrong, I have crossed it out and updated the scenario where the vscode-go extension would register its formatter which is either when
Currently, the problem is not that the vscode-go extension is registering the duplicate formatter. The problem is that The microsoft/vscode#70314 (comment) only talks about half the issue i.e how to unregister a provider
|
Can't VSCode-Go do the configuration handling on its end? Doesn't this handling happen here: Line 144 in 4b516f9
|
I've been taking a look at this from the VSCode end, and I'm a bit stuck on how this should behave. I thought that the extension could register a formatting provider if the server didn't return I tried to implement this via the It's possible I'm completely misunderstanding something, but @dbaeumer's comment (microsoft/vscode#70314 (comment)) shows the behavior of the language server, whereas what we need to do is dispose of a provider when a different provider gets registered. |
How would |
I had hoped that there would be some way for the client to either accept or reject the registration from the language server, but it seems like that's not the case. It seems pretty counter-intuitive to me that the language server should have to be passed settings for which features to register, since to my mind, that's what server and client capabilities are for. This basically means that, if we want to allow the features of the language server to be configured, we have to expose a setting for each of these features to be enabled or disabled. I'm starting to think that perhaps the language server should really be all-or-nothing--it will be extremely hard to debug if each user has a different configuration. The experience with the language server should be as simple as turning it on. My proposal is that we remove the ability to configure these features entirely. I understand that there will be friction, as some users have different preferences. Ideally, this will cause people to file more feature requests, and then the language server can be improved to fit the users' needs. These configurations are just masking the problem. /cc @ianthehat |
I think that the ultimate resolution to this issue would be to remove the @ramya-rao-a: Are there any other concerns here? |
I am ok with the approach of removing |
Absolutely. We can wait on it until such a time as there are no issues with |
The majority of the issues with If we're ready to that, I can add that to #3156. |
Sure, that works |
Closing this issue as with #3156 in the upcoming version of the extension, we drop the support for falling back to the extension's format feature when using the language server. So, there wouldnt be multiple formatting providers being registered at the same time |
For details on the issue see microsoft/vscode#72315
We register 2 formatting providers when the language server is enabled, but the format feature from it is disabled.
We should avoid doing so, and un-register the provider from the language server in such scenario
The text was updated successfully, but these errors were encountered: