From 49343c13e1fe693f304416f6df1ff098ce3410ea Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 17 Jan 2022 12:42:33 -0500 Subject: [PATCH 1/2] chore: update third_party for dprint 0.19 (#13398) --- third_party | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party b/third_party index 233e6ffcd1..c342b5ca99 160000 --- a/third_party +++ b/third_party @@ -1 +1 @@ -Subproject commit 233e6ffcd1af061e63a6bab810eb810f2bbae4bd +Subproject commit c342b5ca997c945ecb36487d7aa4932f0b9b0583 From 3595f37b075b4f1f78081e240f29dfb3060e9225 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 17 Jan 2022 14:45:05 -0500 Subject: [PATCH 2/2] refactor: simplify how LSP deals with config file specifier (#13401) --- cli/lsp/language_server.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index a74db11754..24fbb2021d 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -79,7 +79,6 @@ pub(crate) struct StateSnapshot { pub documents: Documents, pub maybe_lint_config: Option, pub maybe_fmt_config: Option, - pub maybe_config_uri: Option, pub module_registries: registries::ModuleRegistry, pub performance: Performance, pub url_map: urls::LspUrlMap, @@ -114,9 +113,6 @@ pub(crate) struct Inner { maybe_lint_config: Option, /// An optional configuration for formatter which has been taken from specified config file. maybe_fmt_config: Option, - /// An optional URL which provides the location of a TypeScript configuration - /// file which will be used by the Deno LSP. - maybe_config_uri: Option, /// An optional import map which is used to resolve modules. pub(crate) maybe_import_map: Option>, /// The URL for the import map which is used to determine relative imports. @@ -161,7 +157,6 @@ impl Inner { maybe_fmt_config: None, maybe_cache_server: None, maybe_config_file: None, - maybe_config_uri: None, maybe_import_map: None, maybe_import_map_uri: None, module_registries, @@ -293,9 +288,7 @@ impl Inner { /// Returns a tuple with parsed `ConfigFile` and `Url` pointing to that file. /// If there's no config file specified in settings returns `None`. - fn get_config_file_and_url( - &self, - ) -> Result, AnyError> { + fn get_config_file(&self) -> Result, AnyError> { let workspace_settings = self.config.get_workspace_settings(); let maybe_root_uri = self.config.root_uri.clone(); let maybe_config = workspace_settings.config; @@ -317,7 +310,7 @@ impl Inner { lsp_log!(" Resolved configuration file: \"{}\"", config_url); let config_file = ConfigFile::from_specifier(&config_url)?; - return Ok(Some((config_file, config_url))); + return Ok(Some(config_file)); } } @@ -376,7 +369,6 @@ impl Inner { documents: self.documents.clone(), maybe_lint_config: self.maybe_lint_config.clone(), maybe_fmt_config: self.maybe_fmt_config.clone(), - maybe_config_uri: self.maybe_config_uri.clone(), module_registries: self.module_registries.clone(), performance: self.performance.clone(), url_map: self.url_map.clone(), @@ -521,13 +513,10 @@ impl Inner { fn update_config_file(&mut self) -> Result<(), AnyError> { self.maybe_config_file = None; - self.maybe_config_uri = None; self.maybe_fmt_config = None; self.maybe_lint_config = None; - let maybe_file_and_url = self.get_config_file_and_url()?; - - if let Some((config_file, config_url)) = maybe_file_and_url { + if let Some(config_file) = self.get_config_file()? { let lint_config = config_file .to_lint_config() .map_err(|err| { @@ -542,7 +531,6 @@ impl Inner { .unwrap_or_default(); self.maybe_config_file = Some(config_file); - self.maybe_config_uri = Some(config_url); self.maybe_lint_config = Some(lint_config); self.maybe_fmt_config = Some(fmt_config); } @@ -940,8 +928,8 @@ impl Inner { } } // if the current tsconfig has changed, we need to reload it - if let Some(config_uri) = &self.maybe_config_uri { - if changes.iter().any(|uri| config_uri == uri) { + if let Some(config_file) = &self.maybe_config_file { + if changes.iter().any(|uri| config_file.specifier == *uri) { if let Err(err) = self.update_config_file() { self.client.show_message(MessageType::WARNING, err).await; }