From 344f63c6cadef985cea86b9ea16d9440ace54a6e Mon Sep 17 00:00:00 2001 From: "A. Teo Welton" <76081718+teowelton@users.noreply.github.com> Date: Thu, 30 Oct 2025 04:47:44 -0600 Subject: [PATCH] Language: Fix minor C++ completion label formatting issue (#41544) Closes #39515 **Details:** - Improved logic for formatting completion labels, as some (such as `namespace`) were missing space characters. - Added extra logic as per stale PR #39533 [comment](https://github.com/zed-industries/zed/pull/39533#issuecomment-3368549433) ensuring that cases where extra spaces are not necessary (such as functions) are not affected - I will note, I was not able to figure out how to fix the coloring of `namespace` within completion labels as mentioned in that comment, if someone would provide me with direction I would be happy to look into that too. Previous: previous Fixed: fixed Release Notes: - Fixed minor issue where some `clangd` labels would be missing a space in formatting --- crates/languages/src/c.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/c.rs b/crates/languages/src/c.rs index 3463f4505044c83c9ba8a0e602cf5bfa82e93e3f..8e90cf821368c0c88781b2d10e82ad9eaa05989c 100644 --- a/crates/languages/src/c.rs +++ b/crates/languages/src/c.rs @@ -166,13 +166,24 @@ impl super::LspAdapter for CLspAdapter { None => "", }; - let label = completion + let mut label = completion .label .strip_prefix('•') .unwrap_or(&completion.label) .trim() - .to_owned() - + label_detail; + .to_owned(); + + if !label_detail.is_empty() { + let should_add_space = match completion.kind { + Some(lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD) => false, + _ => true, + }; + + if should_add_space && !label.ends_with(' ') && !label_detail.starts_with(' ') { + label.push(' '); + } + label.push_str(label_detail); + } match completion.kind { Some(lsp::CompletionItemKind::FIELD) if completion.detail.is_some() => {