Skip to content

Commit 03b980b

Browse files
authored
Make enabled_feature? return true when all flags are enabled (#2900)
### Motivation When fixing the mistake on the feature flags object composition, I also noticed that the global state wouldn't return `true` if the user had their configuration set as ```json { "rubyLsp.featureFlags": { "all": true } } ``` which is not correct. If they enabled all flags, then checking with `enabled_feature?` should return `true`. ### Implementation Started returning `true` if `all` is enabled. ### Automated Tests Added a test.
1 parent 4a05b2c commit 03b980b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/ruby_lsp/global_state.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def apply_options(options)
146146

147147
sig { params(flag: Symbol).returns(T.nilable(T::Boolean)) }
148148
def enabled_feature?(flag)
149-
@enabled_feature_flags[flag]
149+
@enabled_feature_flags[:all] || @enabled_feature_flags[flag]
150150
end
151151

152152
sig { returns(String) }

test/global_state_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ def test_feature_flags_are_processed_by_apply_options
235235
assert_nil(state.enabled_feature?(:unknown_flag))
236236
end
237237

238+
def test_enabled_feature_always_returns_true_if_all_are_enabled
239+
state = GlobalState.new
240+
241+
state.apply_options({
242+
initializationOptions: {
243+
enabledFeatureFlags: {
244+
all: true,
245+
},
246+
},
247+
})
248+
249+
assert(state.enabled_feature?(:whatever))
250+
end
251+
238252
private
239253

240254
def stub_direct_dependencies(dependencies)

0 commit comments

Comments
 (0)