diff options
author | gfreezy <[email protected]> | 2019-01-20 04:02:00 +0000 |
---|---|---|
committer | gfreezy <[email protected]> | 2019-01-20 04:02:00 +0000 |
commit | 2a43638052213d1faa690e6d68bd5702e44fa027 (patch) | |
tree | 38cb979816dcdff9b9847592a1f99193f0bda70b /crates/ra_lsp_server | |
parent | 94d96b60f334e662f516bd0f04cc4191d7a804e6 (diff) |
use a combination of `source_change` and `text_edit` for `CompleteItem`
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 54a977b7a..23b226fac 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -13,7 +13,6 @@ use ra_syntax::{SyntaxKind, TextRange, TextUnit}; | |||
13 | use ra_text_edit::{AtomTextEdit, TextEdit}; | 13 | use ra_text_edit::{AtomTextEdit, TextEdit}; |
14 | 14 | ||
15 | use crate::{req, server_world::ServerWorld, Result}; | 15 | use crate::{req, server_world::ServerWorld, Result}; |
16 | use ra_text_edit::TextEditBuilder; | ||
17 | 16 | ||
18 | pub trait Conv { | 17 | pub trait Conv { |
19 | type Output; | 18 | type Output; |
@@ -79,13 +78,11 @@ impl ConvWith for CompletionItem { | |||
79 | type Ctx = LineIndex; | 78 | type Ctx = LineIndex; |
80 | type Output = ::lsp_types::CompletionItem; | 79 | type Output = ::lsp_types::CompletionItem; |
81 | 80 | ||
82 | fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { | 81 | fn conv_with(mut self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { |
83 | let atom_text_edit = AtomTextEdit::replace(self.replace_range(), self.insert_text()); | 82 | let atom_text_edit = AtomTextEdit::replace(self.source_range(), self.insert_text()); |
84 | let text_edit = (&atom_text_edit).conv_with(ctx); | 83 | let text_edit = (&atom_text_edit).conv_with(ctx); |
85 | let additional_text_edits = if let Some(delete_range) = self.delete_range() { | 84 | let additional_text_edits = if let Some(edit) = self.take_text_edit() { |
86 | let mut builder = TextEditBuilder::default(); | 85 | Some(edit.conv_with(ctx)) |
87 | builder.delete(delete_range); | ||
88 | Some(builder.finish().conv_with(ctx)) | ||
89 | } else { | 86 | } else { |
90 | None | 87 | None |
91 | }; | 88 | }; |