aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/item.rs')
-rw-r--r--crates/ide_completion/src/item.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs
index cc4ac9ea2..99edb9499 100644
--- a/crates/ide_completion/src/item.rs
+++ b/crates/ide_completion/src/item.rs
@@ -29,7 +29,7 @@ pub struct CompletionItem {
29 /// Range of identifier that is being completed. 29 /// Range of identifier that is being completed.
30 /// 30 ///
31 /// It should be used primarily for UI, but we also use this to convert 31 /// It should be used primarily for UI, but we also use this to convert
32 /// genetic TextEdit into LSP's completion edit (see conv.rs). 32 /// generic TextEdit into LSP's completion edit (see conv.rs).
33 /// 33 ///
34 /// `source_range` must contain the completion offset. `insert_text` should 34 /// `source_range` must contain the completion offset. `insert_text` should
35 /// start with what `source_range` points to, or VSCode will filter out the 35 /// start with what `source_range` points to, or VSCode will filter out the
@@ -377,11 +377,11 @@ impl ImportEdit {
377 pub fn to_text_edit(&self, cfg: InsertUseConfig) -> Option<TextEdit> { 377 pub fn to_text_edit(&self, cfg: InsertUseConfig) -> Option<TextEdit> {
378 let _p = profile::span("ImportEdit::to_text_edit"); 378 let _p = profile::span("ImportEdit::to_text_edit");
379 379
380 let rewriter = 380 let new_ast = self.scope.clone_for_update();
381 insert_use::insert_use(&self.scope, mod_path_to_ast(&self.import.import_path), cfg); 381 insert_use::insert_use(&new_ast, mod_path_to_ast(&self.import.import_path), cfg);
382 let old_ast = rewriter.rewrite_root()?;
383 let mut import_insert = TextEdit::builder(); 382 let mut import_insert = TextEdit::builder();
384 algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut import_insert); 383 algo::diff(self.scope.as_syntax_node(), new_ast.as_syntax_node())
384 .into_text_edit(&mut import_insert);
385 385
386 Some(import_insert.finish()) 386 Some(import_insert.finish())
387 } 387 }