From b5e2040bc27df3d9ec8ee456a9e73325deebee17 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Wed, 14 Aug 2024 10:41:00 -0400 Subject: [PATCH] Consider that the project has a type checker if `sorbet-static` is present as transitive dependency --- lib/ruby_lsp/global_state.rb | 2 +- test/global_state_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ruby_lsp/global_state.rb b/lib/ruby_lsp/global_state.rb index 6a96a9a2d..fe801a2d5 100644 --- a/lib/ruby_lsp/global_state.rb +++ b/lib/ruby_lsp/global_state.rb @@ -93,7 +93,7 @@ def apply_options(options) @test_library = detect_test_library(direct_dependencies) notifications << Notification.window_log_message("Detected test library: #{@test_library}") - @has_type_checker = detect_typechecker(direct_dependencies) + @has_type_checker = detect_typechecker(all_dependencies) if @has_type_checker notifications << Notification.window_log_message( "Ruby LSP detected this is a Sorbet project and will defer to the Sorbet LSP for some functionality", diff --git a/test/global_state_test.rb b/test/global_state_test.rb index 15ac32fb8..1617ca470 100644 --- a/test/global_state_test.rb +++ b/test/global_state_test.rb @@ -199,6 +199,16 @@ def test_apply_options_sets_experimental_features assert_predicate(state, :experimental_features) end + def test_type_checker_is_detected_based_on_transitive_sorbet_static + state = GlobalState.new + + Bundler.locked_gems.stubs(dependencies: {}) + stub_all_dependencies("sorbet-static") + state.apply_options({ initializationOptions: {} }) + + assert_predicate(state, :has_type_checker) + end + private def stub_direct_dependencies(dependencies)