From bed704f8ac5c83f2436016cc4b3a6fb232a875b7 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 7 Aug 2024 10:21:36 +0530 Subject: [PATCH] Ignore non-file workspace URL --- crates/ruff_server/src/session/index.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/ruff_server/src/session/index.rs b/crates/ruff_server/src/session/index.rs index feace554a5445b..e7df1759917d62 100644 --- a/crates/ruff_server/src/session/index.rs +++ b/crates/ruff_server/src/session/index.rs @@ -200,16 +200,20 @@ impl Index { workspace_settings: Option, global_settings: &ClientSettings, ) -> crate::Result<()> { + if workspace_url.scheme() != "file" { + tracing::info!("Ignoring non-file workspace URL: {workspace_url}"); + return Ok(()); + } + let workspace_path = workspace_url.to_file_path().map_err(|()| { + anyhow!("Failed to convert workspace URL to file path: {workspace_url}") + })?; + let client_settings = if let Some(workspace_settings) = workspace_settings { ResolvedClientSettings::with_workspace(&workspace_settings, global_settings) } else { ResolvedClientSettings::global(global_settings) }; - let workspace_path = workspace_url - .to_file_path() - .map_err(|()| anyhow!("workspace URL was not a file path!"))?; - let workspace_settings_index = ruff_settings::RuffSettingsIndex::new( &workspace_path, client_settings.editor_settings(), @@ -227,9 +231,9 @@ impl Index { } pub(super) fn close_workspace_folder(&mut self, workspace_url: &Url) -> crate::Result<()> { - let workspace_path = workspace_url - .to_file_path() - .map_err(|()| anyhow!("workspace URL was not a file path!"))?; + let workspace_path = workspace_url.to_file_path().map_err(|()| { + anyhow!("Failed to convert workspace URL to file path: {workspace_url}") + })?; self.settings.remove(&workspace_path).ok_or_else(|| { anyhow!(