Skip to content

Commit

Permalink
Return VOID by default for unhandled requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Aug 31, 2023
1 parent d361007 commit 24727f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/ruby_lsp/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions test/executor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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
Expand Down

0 comments on commit 24727f7

Please sign in to comment.