From 0ff8c55246d242af2f2fc4f88e67395320d00865 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 26 Feb 2020 13:24:00 +0300 Subject: Unfold groups with single assists into plain assists --- crates/ra_assists/src/assist_ctx.rs | 7 +++++-- crates/ra_assists/src/handlers/auto_import.rs | 7 +------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/ra_assists') 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> { } pub(crate) fn finish(self) -> Option { - assert!(!self.assists.is_empty()); - Some(Assist(self.assists)) + if self.assists.is_empty() { + None + } else { + Some(Assist(self.assists)) + } } } 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 { return None; } - let assist_group_name = if proposed_imports.len() == 1 { - format!("Import `{}`", proposed_imports.iter().next().unwrap()) - } else { - auto_import_assets.get_import_group_message() - }; - let mut group = ctx.add_assist_group(assist_group_name); + let mut group = ctx.add_assist_group(auto_import_assets.get_import_group_message()); for import in proposed_imports { group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| { edit.target(auto_import_assets.syntax_under_caret.text_range()); -- cgit v1.2.3