From dc8fef5dd311e239150dfcd62c90cc84ee32a8a0 Mon Sep 17 00:00:00 2001 From: Andrey Tkachenko Date: Sat, 16 Apr 2022 05:43:54 +0400 Subject: [PATCH] Fixes #1991 LSP Auto-import (#2088) --- helix-lsp/src/client.rs | 7 +++++++ helix-term/src/ui/completion.rs | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 8b14b0b87..14918818d 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -293,6 +293,13 @@ impl Client { completion: Some(lsp::CompletionClientCapabilities { completion_item: Some(lsp::CompletionItemCapability { snippet_support: Some(false), + resolve_support: Some(lsp::CompletionItemCapabilityResolveSupport { + properties: vec![ + String::from("documentation"), + String::from("detail"), + String::from("additionalTextEdits"), + ], + }), ..Default::default() }), completion_item_kind: Some(lsp::CompletionItemKindCapability { diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index 1ee4a01a9..556273bc5 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -178,17 +178,21 @@ impl Completion { }); // apply additional edits, mostly used to auto import unqualified types - let resolved_additional_text_edits = if item.additional_text_edits.is_some() { + let resolved_item = if item + .additional_text_edits + .as_ref() + .map(|edits| !edits.is_empty()) + .unwrap_or(false) + { None } else { Self::resolve_completion_item(doc, item.clone()) - .and_then(|item| item.additional_text_edits) }; - if let Some(additional_edits) = item - .additional_text_edits + if let Some(additional_edits) = resolved_item .as_ref() - .or(resolved_additional_text_edits.as_ref()) + .and_then(|item| item.additional_text_edits.as_ref()) + .or(item.additional_text_edits.as_ref()) { if !additional_edits.is_empty() { let transaction = util::generate_transaction_from_edits(