diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_postfix.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 12 |
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index 555cecb73..60ed3518b 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs | |||
@@ -9,16 +9,14 @@ use crate::{ | |||
9 | }; | 9 | }; |
10 | use hir::{Ty, TypeCtor}; | 10 | use hir::{Ty, TypeCtor}; |
11 | use ra_syntax::{ast::AstNode, TextRange, TextUnit}; | 11 | use ra_syntax::{ast::AstNode, TextRange, TextUnit}; |
12 | use ra_text_edit::TextEditBuilder; | 12 | use ra_text_edit::TextEdit; |
13 | 13 | ||
14 | fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { | 14 | fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { |
15 | let edit = { | 15 | let edit = { |
16 | let receiver_range = | 16 | let receiver_range = |
17 | ctx.dot_receiver.as_ref().expect("no receiver available").syntax().text_range(); | 17 | ctx.dot_receiver.as_ref().expect("no receiver available").syntax().text_range(); |
18 | let delete_range = TextRange::from_to(receiver_range.start(), ctx.source_range().end()); | 18 | let delete_range = TextRange::from_to(receiver_range.start(), ctx.source_range().end()); |
19 | let mut builder = TextEditBuilder::default(); | 19 | TextEdit::replace(delete_range, snippet.to_string()) |
20 | builder.replace(delete_range, snippet.to_string()); | ||
21 | builder.finish() | ||
22 | }; | 20 | }; |
23 | CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label) | 21 | CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label) |
24 | .detail(detail) | 22 | .detail(detail) |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 3e6933bc1..5c9c44704 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -4,7 +4,7 @@ use std::fmt; | |||
4 | 4 | ||
5 | use hir::Documentation; | 5 | use hir::Documentation; |
6 | use ra_syntax::TextRange; | 6 | use ra_syntax::TextRange; |
7 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 7 | use ra_text_edit::TextEdit; |
8 | 8 | ||
9 | /// `CompletionItem` describes a single completion variant in the editor pop-up. | 9 | /// `CompletionItem` describes a single completion variant in the editor pop-up. |
10 | /// It is basically a POD with various properties. To construct a | 10 | /// It is basically a POD with various properties. To construct a |
@@ -192,12 +192,10 @@ impl Builder { | |||
192 | let label = self.label; | 192 | let label = self.label; |
193 | let text_edit = match self.text_edit { | 193 | let text_edit = match self.text_edit { |
194 | Some(it) => it, | 194 | Some(it) => it, |
195 | None => { | 195 | None => TextEdit::replace( |
196 | let mut builder = TextEditBuilder::default(); | 196 | self.source_range, |
197 | builder | 197 | self.insert_text.unwrap_or_else(|| label.clone()), |
198 | .replace(self.source_range, self.insert_text.unwrap_or_else(|| label.clone())); | 198 | ), |
199 | builder.finish() | ||
200 | } | ||
201 | }; | 199 | }; |
202 | 200 | ||
203 | CompletionItem { | 201 | CompletionItem { |