aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/auto_import.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/auto_import.rs')
-rw-r--r--crates/ra_assists/src/auto_import.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 6a0c351f1..b251c9369 100644
--- a/crates/ra_assists/src/auto_import.rs
+++ b/crates/ra_assists/src/auto_import.rs
@@ -480,7 +480,7 @@ fn make_assist_add_nested_import(
480 } 480 }
481} 481}
482 482
483pub(crate) fn auto_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 483pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
484 let node = ctx.covering_node(); 484 let node = ctx.covering_node();
485 let current_file = node.ancestors().find_map(ast::SourceFile::cast)?; 485 let current_file = node.ancestors().find_map(ast::SourceFile::cast)?;
486 486
@@ -495,7 +495,7 @@ pub(crate) fn auto_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
495 return None; 495 return None;
496 } 496 }
497 497
498 ctx.build(format!("import {} in the current file", fmt_segments(&segments)), |edit| { 498 ctx.add_action(format!("import {} in the current file", fmt_segments(&segments)), |edit| {
499 let action = best_action_for_target(current_file.syntax(), path, &segments); 499 let action = best_action_for_target(current_file.syntax(), path, &segments);
500 make_assist(&action, segments.as_slice(), edit); 500 make_assist(&action, segments.as_slice(), edit);
501 if let Some(last_segment) = path.segment() { 501 if let Some(last_segment) = path.segment() {
@@ -506,7 +506,9 @@ pub(crate) fn auto_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
506 last_segment.syntax().range().start(), 506 last_segment.syntax().range().start(),
507 )); 507 ));
508 } 508 }
509 }) 509 });
510
511 ctx.build()
510} 512}
511 513
512#[cfg(test)] 514#[cfg(test)]