From 74ccb3df637a7ba7228e2eb30266d97e40eae0c7 Mon Sep 17 00:00:00 2001 From: Julia Date: Fri, 8 Sep 2023 12:09:31 -0400 Subject: [PATCH] Fix Python's cached binary retrieval being borked Co-Authored-By: Max Brunsfeld --- crates/zed/src/languages/python.rs | 38 +++++++++--------------------- crates/zed/src/languages/rust.rs | 1 + 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/crates/zed/src/languages/python.rs b/crates/zed/src/languages/python.rs index c1539e9590..c10d605a38 100644 --- a/crates/zed/src/languages/python.rs +++ b/crates/zed/src/languages/python.rs @@ -1,6 +1,5 @@ -use anyhow::{anyhow, Result}; +use anyhow::Result; use async_trait::async_trait; -use futures::StreamExt; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; use node_runtime::NodeRuntime; @@ -164,31 +163,16 @@ async fn get_cached_server_binary( container_dir: PathBuf, node: &dyn NodeRuntime, ) -> Option { - (|| async move { - let mut last_version_dir = None; - let mut entries = fs::read_dir(&container_dir).await?; - while let Some(entry) = entries.next().await { - let entry = entry?; - if entry.file_type().await?.is_dir() { - last_version_dir = Some(entry.path()); - } - } - let last_version_dir = last_version_dir.ok_or_else(|| anyhow!("no cached binary"))?; - let server_path = last_version_dir.join(SERVER_PATH); - if server_path.exists() { - Ok(LanguageServerBinary { - path: node.binary_path().await?, - arguments: server_binary_arguments(&server_path), - }) - } else { - Err(anyhow!( - "missing executable in directory {:?}", - last_version_dir - )) - } - })() - .await - .log_err() + let server_path = container_dir.join(SERVER_PATH); + if server_path.exists() { + Some(LanguageServerBinary { + path: node.binary_path().await.log_err()?, + arguments: server_binary_arguments(&server_path), + }) + } else { + log::error!("missing executable in directory {:?}", server_path); + None + } } #[cfg(test)] diff --git a/crates/zed/src/languages/rust.rs b/crates/zed/src/languages/rust.rs index 854eeb7e08..62bdddab5b 100644 --- a/crates/zed/src/languages/rust.rs +++ b/crates/zed/src/languages/rust.rs @@ -262,6 +262,7 @@ impl LspAdapter for RustLspAdapter { }) } } + async fn get_cached_server_binary(container_dir: PathBuf) -> Option { (|| async move { let mut last = None;