ebkalderon / tower-lsp

Language Server Protocol implementation written in Rust
Apache License 2.0
1k stars 55 forks source link

Fix server support for $/cancelRequest #281

Closed ebkalderon closed 3 years ago

ebkalderon commented 3 years ago

It appears that the RequestKind::CancelRequest struct variant is defined incorrectly, meaning client-to-server $/cancelRequest notifications are silently ignored. This seems to have been broken for a long time, apparently since #202.

I discovered this by intentionally adding a 1500ms async delay to the LanguageServer::did_change method in examples/stdio.rs. When this method is invoked on the server, the unexpected delay causes the client to emit a $/cancelRequest notification to the server. After opening a new text buffer and starting to type, I successfully confirmed the $/cancelRequest notification was indeed being emitted by the client, but the server wasn't showing any successful request cancellation logs.

@silvanshade Friendly heads-up: this issue was apparently present in tower-lsp for a while and it seems to affect lspower too. I've added a unit test that ensures that this doesn't break again in the future.