microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.45k stars 325 forks source link

_WindowMiddleware - wrong definition for showDocument #1488

Closed ljw1004 closed 4 months ago

ljw1004 commented 4 months ago

_WindowMiddleware.showDocument request from server to client is missing a "token" parameter. Here is the definition. Observe that the "next" parameter is a function which takes (params: ShowDocumentParams, token: CancellationToken). However, showDocument itself doesn't take a token parameter. Therefore we have nothing to pass when we invoke next(param, ???needToken??).

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/client/src/common/client.ts#L294-L296

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/protocol/src/common/protocol.showDocument.ts#L78-L84

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/jsonrpc/src/common/connection.ts#L89-L91

By comparison, let's look at ConfigurationMiddleware.configuration request from server to client, where the signature of configuration does correctly take a token and is therefore able to pass it to the next function.

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/client/src/common/configuration.ts#L17-L19

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/protocol/src/common/protocol.configuration.ts#L22-L28

ljw1004 commented 4 months ago

I also think the return type of showDocument is wrong. It should allow the possibility to return error, since the next function is able to return error.

https://github.com/microsoft/vscode-languageserver-node/blob/bafd2877a4bd57f187f0d039c2c71539a303f4d5/jsonrpc/src/common/connection.ts#L69