Skip to content

Commit e0057c3

Browse files
committed
perf(language_server): only restart internal linter once when multiple config changes detected (oxc-project#10256)
1 parent 8db5eba commit e0057c3

File tree

1 file changed

+7
-8
lines changed
  • crates/oxc_language_server/src

1 file changed

+7
-8
lines changed

crates/oxc_language_server/src/main.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,7 @@ impl LanguageServer for Backend {
148148
self.init_nested_configs().await;
149149
}
150150

151-
if changed_options.fix_kind() != changed_options.fix_kind() {
152-
self.init_linter_config().await;
153-
self.revalidate_open_files().await;
154-
}
155-
156-
// revalidate the config and all open files
157-
if changed_options.config_path != current_option.config_path {
158-
info!("config path change detected {:?}", &changed_options.config_path);
151+
if Self::needs_linter_restart(current_option, &changed_options) {
159152
self.init_linter_config().await;
160153
self.revalidate_open_files().await;
161154
}
@@ -527,6 +520,12 @@ impl Backend {
527520
.await;
528521
}
529522

523+
fn needs_linter_restart(old_options: &Options, new_options: &Options) -> bool {
524+
old_options.config_path != new_options.config_path
525+
|| old_options.disable_nested_configs() != new_options.disable_nested_configs()
526+
|| old_options.fix_kind() != new_options.fix_kind()
527+
}
528+
530529
/// Searches inside root_uri recursively for the default oxlint config files
531530
/// and insert them inside the nested configuration
532531
async fn init_nested_configs(&self) {

0 commit comments

Comments
 (0)