From 17d7988ad482b8aec7ea9ae2560f055e3a8ee26f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 25 Nov 2025 00:05:16 +0200 Subject: [PATCH] Redact environment variables in server info view (#43436) Follow-up of https://github.com/zed-industries/zed/pull/42831 Release Notes: - N/A --- crates/language_tools/src/lsp_log_view.rs | 27 +++++------------------ crates/lsp/src/lsp.rs | 2 +- crates/project/src/lsp_store.rs | 20 ++--------------- crates/project/src/project.rs | 21 +++++++++++------- 4 files changed, 22 insertions(+), 48 deletions(-) diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index c7aa78067294cbb63266e55a0d05d7abbeefddc2..e7586583704750b0c84832ecb8cb9ba8d5a9b5a1 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -5,6 +5,7 @@ use gpui::{ App, Context, Corner, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, Render, Styled, Subscription, Task, WeakEntity, Window, actions, div, }; +use itertools::Itertools as _; use language::{LanguageServerId, language_settings::SoftWrap}; use lsp::{ LanguageServer, LanguageServerName, LanguageServerSelector, MessageType, SetTraceParams, @@ -12,10 +13,7 @@ use lsp::{ }; use project::{ LanguageServerStatus, Project, - lsp_store::{ - LanguageServerBinaryInfo, - log_store::{self, Event, LanguageServerKind, LogKind, LogStore, Message}, - }, + lsp_store::log_store::{self, Event, LanguageServerKind, LogKind, LogStore, Message}, search::SearchQuery, }; use proto::toggle_lsp_logs::LogType; @@ -351,12 +349,8 @@ impl LspLogView { .status .workspace_folders .iter() - .filter_map(|uri| { - uri.to_file_path() - .ok() - .map(|path| path.to_string_lossy().into_owned()) - }) - .collect::>() + .filter_map(|uri| uri.to_file_path().ok()) + .map(|path| path.to_string_lossy().into_owned()) .join(", "), CAPABILITIES = serde_json::to_string_pretty(&info.capabilities) .unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")), @@ -968,7 +962,7 @@ impl Render for LspLogToolbarItemView { for (server_id, name, worktree_root, active_entry_kind) in available_language_servers.iter() { - let label = format!("{} ({})", name, worktree_root); + let label = format!("{name} ({worktree_root})"); let server_id = *server_id; let active_entry_kind = *active_entry_kind; menu = menu.entry( @@ -1338,16 +1332,7 @@ impl ServerInfo { has_pending_diagnostic_updates: false, progress_tokens: Default::default(), worktree: None, - binary: Some(LanguageServerBinaryInfo { - path: server.binary().path.to_string_lossy().into_owned(), - arguments: server - .binary() - .arguments - .iter() - .map(|arg| arg.to_string_lossy().into_owned()) - .collect(), - env: server.binary().env.clone(), - }), + binary: Some(server.binary().clone()), configuration: Some(server.configuration().clone()), workspace_folders: server.workspace_folders(), }, diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 05771b8ce5db870a41228f81e4aac8222b11ad53..1bc635dcbeca2d38506640b86e547ce90ec76d3d 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -62,7 +62,7 @@ pub enum IoKind { /// Represents a launchable language server. This can either be a standalone binary or the path /// to a runtime with arguments to instruct it to launch the actual language server file. -#[derive(Clone)] +#[derive(Clone, Serialize)] pub struct LanguageServerBinary { pub path: PathBuf, pub arguments: Vec, diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index d18262215198b8a1d7da38a4a325b6f1dcb82084..349bfa9ed00223ea71d4d77dd32bdf433c39c784 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -3729,13 +3729,6 @@ pub enum LspStoreEvent { }, } -#[derive(Clone, Debug, Serialize)] -pub struct LanguageServerBinaryInfo { - pub path: String, - pub arguments: Vec, - pub env: Option>, -} - #[derive(Clone, Debug, Serialize)] pub struct LanguageServerStatus { pub name: LanguageServerName, @@ -3743,7 +3736,7 @@ pub struct LanguageServerStatus { pub has_pending_diagnostic_updates: bool, pub progress_tokens: HashSet, pub worktree: Option, - pub binary: Option, + pub binary: Option, pub configuration: Option, pub workspace_folders: BTreeSet, } @@ -11187,16 +11180,7 @@ impl LspStore { has_pending_diagnostic_updates: false, progress_tokens: Default::default(), worktree: Some(key.worktree_id), - binary: Some(LanguageServerBinaryInfo { - path: language_server.binary().path.to_string_lossy().into_owned(), - arguments: language_server - .binary() - .arguments - .iter() - .map(|arg| arg.to_string_lossy().into_owned()) - .collect(), - env: language_server.binary().env.clone(), - }), + binary: Some(language_server.binary().clone()), configuration: Some(language_server.configuration().clone()), workspace_folders: language_server.workspace_folders(), }, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 8875b3bb6facfb6ce268a38a54585497c8b198cd..149d30a5283c13f71477fc6776d5ca7f61f6205d 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -37,7 +37,7 @@ use dap::inline_value::{InlineValueLocation, VariableLookupKind, VariableScope}; use crate::{ git_store::GitStore, - lsp_store::{LanguageServerBinaryInfo, SymbolLocation, log_store::LogKind}, + lsp_store::{SymbolLocation, log_store::LogKind}, project_search::SearchResultsHandle, }; pub use agent_server_store::{AgentServerStore, AgentServersUpdated, ExternalAgentServerName}; @@ -87,7 +87,8 @@ use language::{ }; use lsp::{ CodeActionKind, CompletionContext, CompletionItemKind, DocumentHighlightKind, InsertTextMode, - LanguageServerId, LanguageServerName, LanguageServerSelector, MessageActionItem, + LanguageServerBinary, LanguageServerId, LanguageServerName, LanguageServerSelector, + MessageActionItem, }; use lsp_command::*; use lsp_store::{CompletionDocumentation, LspFormatTarget, OpenLspBufferHandle}; @@ -111,6 +112,7 @@ use snippet_provider::SnippetProvider; use std::{ borrow::Cow, collections::BTreeMap, + ffi::OsString, ops::{Not as _, Range}, path::{Path, PathBuf}, pin::pin, @@ -3125,12 +3127,15 @@ impl Project { .get_mut(language_server_id) { if let Some(binary) = &update.binary { - language_server_status.binary = - Some(LanguageServerBinaryInfo { - path: binary.path.clone(), - arguments: binary.arguments.clone(), - env: None, - }); + language_server_status.binary = Some(LanguageServerBinary { + path: PathBuf::from(&binary.path), + arguments: binary + .arguments + .iter() + .map(OsString::from) + .collect(), + env: None, + }); } language_server_status.configuration = update