Skip to content

Commit 0df5147

Browse files
committed
fix(language_server): correctly disable nested config search (#11173)
it did not disable nested configs when the flag key is not found
1 parent 4104b01 commit 0df5147

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

crates/oxc_language_server/src/options.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Options {
2323

2424
impl Options {
2525
pub fn use_nested_configs(&self) -> bool {
26-
!self.flags.contains_key("disable_nested_config") || self.config_path.is_some()
26+
!self.flags.contains_key("disable_nested_config") && self.config_path.is_none()
2727
}
2828

2929
pub fn fix_kind(&self) -> FixKind {
@@ -96,6 +96,7 @@ pub struct WorkspaceOption {
9696

9797
#[cfg(test)]
9898
mod test {
99+
use rustc_hash::FxHashMap;
99100
use serde_json::json;
100101

101102
use super::{Options, Run, WorkspaceOption};
@@ -178,4 +179,20 @@ mod test {
178179
assert_eq!(options.config_path, Some("./custom.json".into()));
179180
assert!(options.flags.is_empty());
180181
}
182+
183+
#[test]
184+
fn test_use_nested_configs() {
185+
let options = Options::default();
186+
assert!(options.use_nested_configs());
187+
188+
let options =
189+
Options { config_path: Some("config.json".to_string()), ..Default::default() };
190+
assert!(!options.use_nested_configs());
191+
192+
let mut flags = FxHashMap::default();
193+
flags.insert("disable_nested_config".to_string(), "true".to_string());
194+
195+
let options = Options { flags, ..Default::default() };
196+
assert!(!options.use_nested_configs());
197+
}
181198
}

0 commit comments

Comments
 (0)