aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tobias Wirth <[email protected]>2021-05-20 22:22:21 +0100
committerLukas Tobias Wirth <[email protected]>2021-05-20 22:22:21 +0100
commit6b0ac95df1be5a6423d4141710100f01b3f84b48 (patch)
tree9700d0ff7b282153242d389dcb21d3d1eb6e3782
parent8bb37737c9e8b7a390ae29d5fb0daaeeb495d2b5 (diff)
Fix code completion not inserting borrow text when client supports InsertAndReplace
-rw-r--r--crates/rust-analyzer/src/to_proto.rs9
1 files changed, 6 insertions, 3 deletions
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(
270 set_score(&mut lsp_item_with_ref, relevance); 270 set_score(&mut lsp_item_with_ref, relevance);
271 lsp_item_with_ref.label = 271 lsp_item_with_ref.label =
272 format!("&{}{}", mutability.as_keyword_for_ref(), lsp_item_with_ref.label); 272 format!("&{}{}", mutability.as_keyword_for_ref(), lsp_item_with_ref.label);
273 if let Some(lsp_types::CompletionTextEdit::Edit(it)) = &mut lsp_item_with_ref.text_edit 273 if let Some(it) = &mut lsp_item_with_ref.text_edit {
274 { 274 let new_text = match it {
275 it.new_text = format!("&{}{}", mutability.as_keyword_for_ref(), it.new_text); 275 lsp_types::CompletionTextEdit::Edit(it) => &mut it.new_text,
276 lsp_types::CompletionTextEdit::InsertAndReplace(it) => &mut it.new_text,
277 };
278 *new_text = format!("&{}{}", mutability.as_keyword_for_ref(), new_text);
276 } 279 }
277 vec![lsp_item_with_ref, lsp_item] 280 vec![lsp_item_with_ref, lsp_item]
278 } 281 }