Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove installation test binary from language server instance
Julia7caa096bd002
diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rsindex 866bb8d7f52..4c45bf823bf 100644--- a/crates/copilot/src/copilot.rs+++ b/crates/copilot/src/copilot.rs@@ -15,7 +15,7 @@ use language::{ToPointUtf16,};use log::{debug, error};-use lsp::{LanguageServer, LanguageServerBinaries, LanguageServerBinary, LanguageServerId};+use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId};use node_runtime::NodeRuntime;use request::{LogMessage, StatusNotification};use settings::SettingsStore;@@ -366,13 +366,9 @@ impl Copilot {path: node_path,arguments,};- let binaries = LanguageServerBinaries {- binary: binary.clone(),- installation_test_binary: Some(binary),- };let server = LanguageServer::new(LanguageServerId(0),- binaries,+ binary,Path::new("/"),None,cx.clone(),diff --git a/crates/language/src/language.rs b/crates/language/src/language.rsindex 9e3d3708ba7..beec63dfd24 100644--- a/crates/language/src/language.rs+++ b/crates/language/src/language.rs@@ -20,7 +20,7 @@ use futures::{use gpui::{executor::Background, AppContext, AsyncAppContext, Task};use highlight_map::HighlightMap;use lazy_static::lazy_static;-use lsp::{CodeActionKind, LanguageServerBinaries, LanguageServerBinary};+use lsp::{CodeActionKind, LanguageServerBinary};use parking_lot::{Mutex, RwLock};use postage::watch;use regex::Regex;@@ -564,10 +564,7 @@ pub struct LanguageRegistry {login_shell_env_loaded: Shared<Task<()>>,#[allow(clippy::type_complexity)]lsp_binary_paths: Mutex<- HashMap<- LanguageServerName,- Shared<Task<Result<LanguageServerBinaries, Arc<anyhow::Error>>>>,- >,+ HashMap<LanguageServerName, Shared<Task<Result<LanguageServerBinary, Arc<anyhow::Error>>>>>,>,executor: Option<Arc<Background>>,}@@ -859,7 +856,7 @@ impl LanguageRegistry {self.state.read().languages.iter().cloned().collect()}- pub fn start_pending_language_server(+ pub fn create_pending_language_server(self: &Arc<Self>,language: Arc<Language>,adapter: Arc<CachedLspAdapter>,@@ -932,7 +929,7 @@ impl LanguageRegistry {.entry(adapter.name.clone()).or_insert_with(|| {cx.spawn(|cx| {- get_binaries(+ get_binary(adapter.clone(),language.clone(),delegate.clone(),@@ -953,15 +950,13 @@ impl LanguageRegistry {task.await?;}- let server = lsp::LanguageServer::new(+ lsp::LanguageServer::new(server_id,binaries,&root_path,adapter.code_action_kinds(),cx,- )?;-- Ok(server)+ )})};@@ -1047,14 +1042,14 @@ impl Default for LanguageRegistry {}}-async fn get_binaries(+async fn get_binary(adapter: Arc<CachedLspAdapter>,language: Arc<Language>,delegate: Arc<dyn LspAdapterDelegate>,container_dir: Arc<Path>,statuses: async_broadcast::Sender<(Arc<Language>, LanguageServerBinaryStatus)>,mut cx: AsyncAppContext,-) -> Result<LanguageServerBinaries> {+) -> Result<LanguageServerBinary> {if !container_dir.exists() {smol::fs::create_dir_all(&container_dir).await@@ -1082,13 +1077,7 @@ async fn get_binaries(statuses.broadcast((language.clone(), LanguageServerBinaryStatus::Cached)).await?;- let installation_test_binary = adapter- .installation_test_binary(container_dir.to_path_buf())- .await;- return Ok(LanguageServerBinaries {- binary,- installation_test_binary,- });+ return Ok(binary);} else {statuses.broadcast((@@ -1110,7 +1099,7 @@ async fn fetch_latest_binary(delegate: &dyn LspAdapterDelegate,container_dir: &Path,lsp_binary_statuses_tx: async_broadcast::Sender<(Arc<Language>, LanguageServerBinaryStatus)>,-) -> Result<LanguageServerBinaries> {+) -> Result<LanguageServerBinary> {let container_dir: Arc<Path> = container_dir.into();lsp_binary_statuses_tx.broadcast((@@ -1127,17 +1116,11 @@ async fn fetch_latest_binary(let binary = adapter.fetch_server_binary(version_info, container_dir.to_path_buf(), delegate).await?;- let installation_test_binary = adapter- .installation_test_binary(container_dir.to_path_buf())- .await;lsp_binary_statuses_tx.broadcast((language.clone(), LanguageServerBinaryStatus::Downloaded)).await?;- Ok(LanguageServerBinaries {- binary,- installation_test_binary,- })+ Ok(binary)}impl Language {diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rsindex deab1d9cc06..ffca2f24abf 100644--- a/crates/lsp/src/lsp.rs+++ b/crates/lsp/src/lsp.rs@@ -43,12 +43,6 @@ pub struct LanguageServerBinary {pub arguments: Vec<OsString>,}-#[derive(Debug, Clone, Deserialize)]-pub struct LanguageServerBinaries {- pub binary: LanguageServerBinary,- pub installation_test_binary: Option<LanguageServerBinary>,-}-pub struct LanguageServer {server_id: LanguageServerId,next_id: AtomicUsize,@@ -65,7 +59,6 @@ pub struct LanguageServer {output_done_rx: Mutex<Option<barrier::Receiver>>,root_path: PathBuf,_server: Option<Mutex<Child>>,- installation_test_binary: Option<LanguageServerBinary>,}#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]@@ -135,7 +128,7 @@ struct Error {impl LanguageServer {pub fn new(server_id: LanguageServerId,- binaries: LanguageServerBinaries,+ binary: LanguageServerBinary,root_path: &Path,code_action_kinds: Option<Vec<CodeActionKind>>,cx: AsyncAppContext,@@ -146,9 +139,9 @@ impl LanguageServer {root_path.parent().unwrap_or_else(|| Path::new("/"))};- let mut server = process::Command::new(&binaries.binary.path)+ let mut server = process::Command::new(&binary.path).current_dir(working_dir)- .args(binaries.binary.arguments)+ .args(binary.arguments).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::inherit())@@ -162,7 +155,6 @@ impl LanguageServer {stdin,stout,Some(server),- binaries.installation_test_binary,root_path,code_action_kinds,cx,@@ -181,7 +173,7 @@ impl LanguageServer {},);- if let Some(name) = binaries.binary.path.file_name() {+ if let Some(name) = binary.path.file_name() {server.name = name.to_string_lossy().to_string();}@@ -193,7 +185,6 @@ impl LanguageServer {stdin: Stdin,stdout: Stdout,server: Option<Child>,- installation_test_binary: Option<LanguageServerBinary>,root_path: &Path,code_action_kinds: Option<Vec<CodeActionKind>>,cx: AsyncAppContext,@@ -248,14 +239,9 @@ impl LanguageServer {output_done_rx: Mutex::new(Some(output_done_rx)),root_path: root_path.to_path_buf(),_server: server.map(|server| Mutex::new(server)),- installation_test_binary,}}- pub fn installation_test_binary(&self) -> &Option<LanguageServerBinary> {- &self.installation_test_binary- }-pub fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>> {self.code_action_kinds.clone()}@@ -840,7 +826,6 @@ impl LanguageServer {stdin_writer,stdout_reader,None,- None,Path::new("/"),None,cx.clone(),@@ -852,7 +837,6 @@ impl LanguageServer {stdout_writer,stdin_reader,None,- None,Path::new("/"),None,cx,diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex a33a47779c2..4c6b25b0e90 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -2423,7 +2423,7 @@ impl Project {return;}- let pending_server = match self.languages.start_pending_language_server(+ let pending_server = match self.languages.create_pending_language_server(language.clone(),adapter.clone(),worktree_path,