Skip to content

Commit 664342b

Browse files
committed
fix(language_server): diable nested configuration when config path is provided (#10385)
This is the same behavior as oxlint: https://github.com/oxc-project/oxc/blob/2e1ef4cbdea47d4da7b893e4374e94172a34bf5c/apps/oxlint/src/lint.rs#L63-L66
1 parent 62f7d76 commit 664342b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • crates/oxc_language_server/src

crates/oxc_language_server/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ struct Options {
6363
}
6464

6565
impl Options {
66-
fn disable_nested_configs(&self) -> bool {
67-
self.flags.contains_key("disable_nested_config")
66+
fn use_nested_configs(&self) -> bool {
67+
!self.flags.contains_key("disable_nested_config") || self.config_path.is_some()
6868
}
6969

7070
fn fix_kind(&self) -> FixKind {
@@ -143,7 +143,7 @@ impl LanguageServer for Backend {
143143

144144
*self.options.lock().await = changed_options.clone();
145145

146-
if changed_options.disable_nested_configs() != current_option.disable_nested_configs() {
146+
if changed_options.use_nested_configs() != current_option.use_nested_configs() {
147147
self.nested_configs.pin().clear();
148148
self.init_nested_configs().await;
149149
}
@@ -156,7 +156,7 @@ impl LanguageServer for Backend {
156156

157157
async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) {
158158
debug!("watched file did change");
159-
if !self.options.lock().await.disable_nested_configs() {
159+
if self.options.lock().await.use_nested_configs() {
160160
let nested_configs = self.nested_configs.pin();
161161

162162
params.changes.iter().for_each(|x| {
@@ -508,7 +508,7 @@ impl Backend {
508508

509509
fn needs_linter_restart(old_options: &Options, new_options: &Options) -> bool {
510510
old_options.config_path != new_options.config_path
511-
|| old_options.disable_nested_configs() != new_options.disable_nested_configs()
511+
|| old_options.use_nested_configs() != new_options.use_nested_configs()
512512
|| old_options.fix_kind() != new_options.fix_kind()
513513
}
514514

@@ -523,7 +523,7 @@ impl Backend {
523523
};
524524

525525
// nested config is disabled, no need to search for configs
526-
if self.options.lock().await.disable_nested_configs() {
526+
if !self.options.lock().await.use_nested_configs() {
527527
return;
528528
}
529529

@@ -578,16 +578,16 @@ impl Backend {
578578
let lint_options =
579579
LintOptions { fix: self.options.lock().await.fix_kind(), ..Default::default() };
580580

581-
let linter = if self.options.lock().await.disable_nested_configs() {
582-
Linter::new(lint_options, config_store)
583-
} else {
581+
let linter = if self.options.lock().await.use_nested_configs() {
584582
let nested_configs = self.nested_configs.pin();
585583
let nested_configs_copy: FxHashMap<PathBuf, ConfigStore> = nested_configs
586584
.iter()
587585
.map(|(key, value)| (key.clone(), value.clone()))
588586
.collect::<FxHashMap<_, _>>();
589587

590588
Linter::new_with_nested_configs(lint_options, config_store, nested_configs_copy)
589+
} else {
590+
Linter::new(lint_options, config_store)
591591
};
592592

593593
*self.server_linter.write().await = ServerLinter::new_with_linter(linter);

0 commit comments

Comments
 (0)