From 63a4bce2d6864e17d2048a3f90f7f3420aab6cea Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 1 Sep 2023 09:15:29 -0400 Subject: [PATCH] Return `VOID` by default for unhandled requests (#961) --- lib/ruby_lsp/executor.rb | 2 ++ test/executor_test.rb | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ruby_lsp/executor.rb b/lib/ruby_lsp/executor.rb index eadb00150..b13de45e1 100644 --- a/lib/ruby_lsp/executor.rb +++ b/lib/ruby_lsp/executor.rb @@ -178,6 +178,8 @@ def run(request) workspace_symbol(request.dig(:params, :query)) when "rubyLsp/textDocument/showSyntaxTree" show_syntax_tree(uri, request.dig(:params, :range)) + else + VOID end end diff --git a/test/executor_test.rb b/test/executor_test.rb index 076abe6e0..debbd03c1 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -217,6 +217,15 @@ def test_shows_error_if_formatter_set_to_rubocop_but_rubocop_not_available end end + def test_returns_void_for_unhandled_request + executor = RubyLsp::Executor.new(@store, @message_queue) + + result = executor.execute(method: "anything/not/existing", params: {}) + assert_same(RubyLsp::VOID, result.response) + end + + private + def with_uninstalled_rubocop(&block) rubocop_paths = $LOAD_PATH.select { |path| path.include?("gems/rubocop") } rubocop_paths.each { |path| $LOAD_PATH.delete(path) } @@ -237,8 +246,6 @@ def unload_rubocop_runner # Depending on which tests have run prior to this one, `RuboCopRunner` may or may not be defined end - private - def stub_dependencies(rubocop:, syntax_tree:) dependencies = {} dependencies["syntax_tree"] = "..." if syntax_tree