From 6b0ac95df1be5a6423d4141710100f01b3f84b48 Mon Sep 17 00:00:00 2001 From: Lukas Tobias Wirth Date: Thu, 20 May 2021 23:22:21 +0200 Subject: Fix code completion not inserting borrow text when client supports InsertAndReplace --- crates/rust-analyzer/src/to_proto.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/rust-analyzer/src/to_proto.rs') diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index ef9e0aee9..0a3a56773 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -270,9 +270,12 @@ pub(crate) fn completion_item( set_score(&mut lsp_item_with_ref, relevance); lsp_item_with_ref.label = format!("&{}{}", mutability.as_keyword_for_ref(), lsp_item_with_ref.label); - if let Some(lsp_types::CompletionTextEdit::Edit(it)) = &mut lsp_item_with_ref.text_edit - { - it.new_text = format!("&{}{}", mutability.as_keyword_for_ref(), it.new_text); + if let Some(it) = &mut lsp_item_with_ref.text_edit { + let new_text = match it { + lsp_types::CompletionTextEdit::Edit(it) => &mut it.new_text, + lsp_types::CompletionTextEdit::InsertAndReplace(it) => &mut it.new_text, + }; + *new_text = format!("&{}{}", mutability.as_keyword_for_ref(), new_text); } vec![lsp_item_with_ref, lsp_item] } -- cgit v1.2.3