diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-02-05 17:41:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 17:41:15 -0500 |
commit | 8cc9a9350b8a8c8fb883a93fc78471ccdd545481 (patch) | |
tree | 676be9ede3f2adf5a32afdd94b773462fa9b8d38 /cli/lsp/language_server.rs | |
parent | 592b1fb911765802fd5d6cb774995f2617dec59c (diff) |
fix(lsp): do not panic getting root_uri to auto discover configuration file (#13603)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r-- | cli/lsp/language_server.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 1d91a4b37..bf7be3ea7 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -309,14 +309,13 @@ impl Inner { /// If there's no config file specified in settings returns `None`. fn get_config_file(&self) -> Result<Option<ConfigFile>, AnyError> { let workspace_settings = self.config.get_workspace_settings(); - let maybe_root_uri = self.root_uri.clone(); let maybe_config = workspace_settings.config; if let Some(config_str) = &maybe_config { if !config_str.is_empty() { lsp_log!("Setting TypeScript configuration from: \"{}\"", config_str); let config_url = if let Ok(url) = Url::from_file_path(config_str) { Ok(url) - } else if let Some(root_uri) = maybe_root_uri { + } else if let Some(root_uri) = &self.root_uri { root_uri.join(config_str).map_err(|_| { anyhow!("Bad file path for configuration file: \"{}\"", config_str) }) @@ -338,8 +337,8 @@ impl Inner { // It is possible that root_uri is not set, for example when having a single // file open and not a workspace. In those situations we can't // automatically discover the configuration - if let Some(root_uri) = maybe_root_uri { - let root_path = root_uri.to_file_path().unwrap(); + if let Some(root_uri) = &self.root_uri { + let root_path = fs_util::specifier_to_file_path(root_uri)?; let mut checked = std::collections::HashSet::new(); let maybe_config = crate::config_file::discover_from(&root_path, &mut checked)?; |