diff --git a/lib/ruby_lsp/base_server.rb b/lib/ruby_lsp/base_server.rb index 1cc086763..49c813a88 100644 --- a/lib/ruby_lsp/base_server.rb +++ b/lib/ruby_lsp/base_server.rb @@ -158,11 +158,7 @@ def new_worker # Check if the request was cancelled before trying to process it @global_state.synchronize do if id && @cancelled_requests.include?(id) - send_message(Error.new( - id: id, - code: Constant::ErrorCodes::REQUEST_CANCELLED, - message: "Request #{id} was cancelled", - )) + send_message(Result.new(id: id, response: nil)) @cancelled_requests.delete(id) next end diff --git a/test/server_test.rb b/test/server_test.rb index 735ace549..b430deb33 100644 --- a/test/server_test.rb +++ b/test/server_test.rb @@ -751,7 +751,7 @@ def test_requests_to_a_non_existing_position_return_error assert_match("Request textDocument/completion failed to find the target position.", error.message) end - def test_cancelling_requests_returns_expected_error_code + def test_cancelling_requests_returns_nil uri = URI("file:///foo.rb") @server.process_message({ @@ -791,9 +791,8 @@ def test_cancelling_requests_returns_expected_error_code mutex.unlock thread.join - error = find_message(RubyLsp::Error) - assert_equal(RubyLsp::Constant::ErrorCodes::REQUEST_CANCELLED, error.code) - assert_equal("Request 1 was cancelled", error.message) + result = find_message(RubyLsp::Result) + assert_nil(result.response) end def test_unsaved_changes_are_indexed_when_computing_automatic_features