aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/assist_ctx.rs7
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs7
2 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index c25d2e323..62182cf03 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -166,8 +166,11 @@ impl<'a> AssistGroup<'a> {
166 } 166 }
167 167
168 pub(crate) fn finish(self) -> Option<Assist> { 168 pub(crate) fn finish(self) -> Option<Assist> {
169 assert!(!self.assists.is_empty()); 169 if self.assists.is_empty() {
170 Some(Assist(self.assists)) 170 None
171 } else {
172 Some(Assist(self.assists))
173 }
171 } 174 }
172} 175}
173 176
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs
index c8bf181f9..4b62aac48 100644
--- a/crates/ra_assists/src/handlers/auto_import.rs
+++ b/crates/ra_assists/src/handlers/auto_import.rs
@@ -42,12 +42,7 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
42 return None; 42 return None;
43 } 43 }
44 44
45 let assist_group_name = if proposed_imports.len() == 1 { 45 let mut group = ctx.add_assist_group(auto_import_assets.get_import_group_message());
46 format!("Import `{}`", proposed_imports.iter().next().unwrap())
47 } else {
48 auto_import_assets.get_import_group_message()
49 };
50 let mut group = ctx.add_assist_group(assist_group_name);
51 for import in proposed_imports { 46 for import in proposed_imports {
52 group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| { 47 group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| {
53 edit.target(auto_import_assets.syntax_under_caret.text_range()); 48 edit.target(auto_import_assets.syntax_under_caret.text_range());