From c36f877f8d98f9756154e26809c614d6749b3fd1 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 18 Nov 2024 21:45:34 +0000 Subject: [PATCH] fix(lsp): ignore editor indent settings if deno.json is present (#26912) --- cli/lsp/language_server.rs | 6 ++++-- tests/integration/lsp_tests.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index c93628555b..2ce26c1f2e 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1396,9 +1396,11 @@ impl Inner { .fmt_config_for_specifier(&specifier) .options .clone(); - fmt_options.use_tabs = Some(!params.options.insert_spaces); - fmt_options.indent_width = Some(params.options.tab_size as u8); let config_data = self.config.tree.data_for_specifier(&specifier); + if !config_data.is_some_and(|d| d.maybe_deno_json().is_some()) { + fmt_options.use_tabs = Some(!params.options.insert_spaces); + fmt_options.indent_width = Some(params.options.tab_size as u8); + } let unstable_options = UnstableFmtOptions { component: config_data .map(|d| d.unstable.contains("fmt-component")) diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index a5b0ee2471..8eaccb5487 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -11680,7 +11680,7 @@ fn lsp_format_with_config() { }, "options": { "tabSize": 2, - "insertSpaces": false + "insertSpaces": true, } }), );