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

onNotification can only have one event handler per type - consider allowing multiple? #299

Closed
CRogers opened this issue Jan 2, 2018 · 7 comments
Labels
info-needed Issue requires more information from poster

Comments

@CRogers
Copy link

CRogers commented Jan 2, 2018

I spent a large chunk of time today tracking down a bug I'd introduced; it looks like LanguageClient#onNotification can only have one handler per notification type, and silently overwrites the old handler when given a new one:

https://github.com/Microsoft/vscode-languageserver-node/blob/fd152c3961eea1a74547932d157d7351764c1dbf/jsonrpc/src/main.ts#L898

This goes very much against what I'd expect to be able to do, which is to register multiple handlers for the same notification type.

In particular, I'm trying to add vscode decorations for haskell "typed holes" which are hacked into the haskell compiler as error messages but need a faster feedback than hovering the mouse:

screen shot 2018-01-02 at 11 02 19 pm

I want to augment the existing error reporting provided by the default vscode language client implementation but can't do it without removing that default publish diagnostic handler at the moment :/

CRogers added a commit to CRogers/vscode-hie-server that referenced this issue Jan 2, 2018
@dbaeumer
Copy link
Member

dbaeumer commented Jan 8, 2018

The problem here is that although this is possible for notifications it is not for requests (due to the response). To keep things consistent I made them 'singletons' for both notifications and requests and called them handlers and not event listeners.

I am reluctant to change this for handlers since it makes things inconsistent. Instead we should route the diagnostic notification through the client middleware so that the result can be inspected there and further action can be taken. We route all the request through the middleware as well for that purpose.

@CRogers are you willing to look into a PR for this?

@dbaeumer dbaeumer added this to the On Deck milestone Jan 8, 2018
@CRogers
Copy link
Author

CRogers commented Jan 8, 2018 via email

@dbaeumer
Copy link
Member

dbaeumer commented Jan 8, 2018

The middle ware is defined in client.ts: https://github.com/Microsoft/vscode-languageserver-node/blob/master/client\src\client.ts#L399

We should add a signature for publishDiagnostics with the types from the LSP (since the message comes from the server to intercept it as early as possible). The code that currently published the diagnostics should pass them to the middleware if it provides a special handler and should pass the current publish code in the next handler.

@rcjsuen
Copy link
Contributor

rcjsuen commented Mar 18, 2018

I've opened #322 to address this.

@rcjsuen
Copy link
Contributor

rcjsuen commented Apr 6, 2018

@CRogers #322 has been merged so there should be a new middleware handleDiagnostics function available for you to inspect the diagnostics before VS Code "knows" about it. Please update to version 4.1.3 of vscode-languageclient and see if it satisfies your need.

@dbaeumer
Copy link
Member

dbaeumer commented Apr 6, 2018

@rcjsuen thanks for pointing @CRogers to this.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Apr 6, 2018
@vscodebot
Copy link

vscodebot bot commented Apr 13, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Apr 13, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators May 28, 2018
@dbaeumer dbaeumer removed this from the On Deck milestone Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants