diff --git a/Cargo.lock b/Cargo.lock index 26fce3c46b8b6c7f754f9f82803097769d70b409..8642aaa58d9abed9a289e979b46919a162e0daba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9015,6 +9015,7 @@ dependencies = [ "collections", "copilot", "editor", + "feature_flags", "futures 0.3.31", "gpui", "itertools 0.14.0", diff --git a/crates/language_tools/Cargo.toml b/crates/language_tools/Cargo.toml index 3a0f487f7a17ddc3a43550a998590c5aa937a19a..ffdc939809145b319d5421adf5b8a923604e74fe 100644 --- a/crates/language_tools/Cargo.toml +++ b/crates/language_tools/Cargo.toml @@ -18,6 +18,7 @@ client.workspace = true collections.workspace = true copilot.workspace = true editor.workspace = true +feature_flags.workspace = true futures.workspace = true gpui.workspace = true itertools.workspace = true diff --git a/crates/language_tools/src/lsp_tool.rs b/crates/language_tools/src/lsp_tool.rs index fc1efc7794eb33986cb26ecbd0941075111da700..a7bfe70aaf7055173b6d7ce27ebde46570bf5493 100644 --- a/crates/language_tools/src/lsp_tool.rs +++ b/crates/language_tools/src/lsp_tool.rs @@ -3,6 +3,7 @@ use std::{collections::hash_map, path::PathBuf, sync::Arc, time::Duration}; use client::proto; use collections::{HashMap, HashSet}; use editor::{Editor, EditorEvent}; +use feature_flags::FeatureFlagAppExt as _; use gpui::{Corner, DismissEvent, Entity, Focusable as _, Subscription, Task, WeakEntity, actions}; use language::{BinaryStatus, BufferId, LocalFile, ServerHealth}; use lsp::{LanguageServerId, LanguageServerName, LanguageServerSelector}; @@ -244,6 +245,10 @@ impl LanguageServers { ); } } + + fn is_empty(&self) -> bool { + self.binary_statuses.is_empty() && self.health_statuses.is_empty() + } } #[derive(Debug)] @@ -865,6 +870,10 @@ impl StatusItemView for LspTool { impl Render for LspTool { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl ui::IntoElement { + if !cx.is_staff() || self.state.read(cx).language_servers.is_empty() { + return div(); + } + let Some(lsp_picker) = self.lsp_picker.clone() else { return div(); }; diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index d6f5d7a3cc98a872a1ce6822c88b6fee8599540e..950e391a1d3c7aed91e00b99da314d1f36a069d0 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -2484,11 +2484,11 @@ impl LocalLspStore { } } }; - let lsp_tool = self.weak.clone(); + let lsp_store = self.weak.clone(); let server_name = server_node.name(); let buffer_abs_path = abs_path.to_string_lossy().to_string(); cx.defer(move |cx| { - lsp_tool.update(cx, |_, cx| cx.emit(LspStoreEvent::LanguageServerUpdate { + lsp_store.update(cx, |_, cx| cx.emit(LspStoreEvent::LanguageServerUpdate { language_server_id: server_id, name: server_name, message: proto::update_language_server::Variant::RegisteredForBuffer(proto::RegisteredForBuffer {