From 0d25534b18372657d197acc7e9079170757e11e2 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 21 Nov 2024 16:09:07 -0500 Subject: [PATCH] Make `enabled_feature?` return true when all flags are enabled --- lib/ruby_lsp/global_state.rb | 2 +- test/global_state_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/ruby_lsp/global_state.rb b/lib/ruby_lsp/global_state.rb index df0eee261..004df40d9 100644 --- a/lib/ruby_lsp/global_state.rb +++ b/lib/ruby_lsp/global_state.rb @@ -146,7 +146,7 @@ def apply_options(options) sig { params(flag: Symbol).returns(T.nilable(T::Boolean)) } def enabled_feature?(flag) - @enabled_feature_flags[flag] + @enabled_feature_flags[:all] || @enabled_feature_flags[flag] end sig { returns(String) } diff --git a/test/global_state_test.rb b/test/global_state_test.rb index 02dc0ee66..b655dcbfe 100644 --- a/test/global_state_test.rb +++ b/test/global_state_test.rb @@ -235,6 +235,20 @@ def test_feature_flags_are_processed_by_apply_options assert_nil(state.enabled_feature?(:unknown_flag)) end + def test_enabled_feature_always_returns_true_if_all_are_enabled + state = GlobalState.new + + state.apply_options({ + initializationOptions: { + enabledFeatureFlags: { + all: true, + }, + }, + }) + + assert(state.enabled_feature?(:whatever)) + end + private def stub_direct_dependencies(dependencies)