Skip to content

Commit f57323e

Browse files
authored
handle cancel correctly (#289)
* handle cancel correctly * move paren
1 parent 7fda2ab commit f57323e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pyls/rpc_manager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
from jsonrpc.exceptions import JSONRPCMethodNotFound, JSONRPCDispatchException, JSONRPCServerError
1111

1212
log = logging.getLogger(__name__)
13-
1413
RESPONSE_CLASS_MAP = {
1514
"1.0": JSONRPC10Response,
1615
"2.0": JSONRPC20Response
1716
}
17+
# as defined in https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md
18+
LSP_CANCEL_CODE = -32800
1819

1920

2021
class MissingMethodException(Exception):
@@ -83,7 +84,9 @@ def cancel(self, request_id):
8384
"""
8485
log.debug('Cancel request %d', request_id)
8586
try:
86-
self._received_requests[request_id].cancel()
87+
self._received_requests[request_id].set_exception(
88+
JSONRPCDispatchException(code=LSP_CANCEL_CODE, message="Request cancelled")
89+
)
8790
except KeyError:
8891
log.debug('Received cancel for finished/nonexistent request %d', request_id)
8992

0 commit comments

Comments
 (0)