Skip to content

Commit

Permalink
Make enabled_feature? return true when all flags are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Nov 21, 2024
1 parent d719b86 commit 79d33e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ruby_lsp/global_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
14 changes: 14 additions & 0 deletions test/global_state_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 79d33e5

Please sign in to comment.