diff --git a/pyls/rpc_manager.py b/pyls/rpc_manager.py index 2bc297d6..3015a8a3 100644 --- a/pyls/rpc_manager.py +++ b/pyls/rpc_manager.py @@ -10,11 +10,12 @@ from jsonrpc.exceptions import JSONRPCMethodNotFound, JSONRPCDispatchException, JSONRPCServerError log = logging.getLogger(__name__) - RESPONSE_CLASS_MAP = { "1.0": JSONRPC10Response, "2.0": JSONRPC20Response } +# as defined in https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md +LSP_CANCEL_CODE = -32800 class MissingMethodException(Exception): @@ -83,7 +84,9 @@ def cancel(self, request_id): """ log.debug('Cancel request %d', request_id) try: - self._received_requests[request_id].cancel() + self._received_requests[request_id].set_exception( + JSONRPCDispatchException(code=LSP_CANCEL_CODE, message="Request cancelled") + ) except KeyError: log.debug('Received cancel for finished/nonexistent request %d', request_id)