From 2fe6e23138d990a852a59d9680847cb6718565bb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Mar 2020 14:52:20 +0200 Subject: When adding match arm, don't let the floating comma --- crates/ra_assists/src/handlers/fill_match_arms.rs | 30 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 41bb97928..8d1af9933 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -1,15 +1,11 @@ -//! FIXME: write short doc here - use std::iter; use hir::{Adt, HasSource, ModuleDef, Semantics}; use itertools::Itertools; use ra_ide_db::RootDatabase; +use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; use crate::{Assist, AssistCtx, AssistId}; -use ra_syntax::ast::{self, make, AstNode, NameOwner}; - -use ast::{MatchArm, Pat}; // Assist: fill_match_arms // @@ -717,4 +713,28 @@ mod tests { "#, ); } + + #[test] + fn fill_match_arms_placeholder() { + check_assist( + fill_match_arms, + r#" + enum A { One, Two, } + fn foo(a: A) { + match a<|> { + _ => (), + } + } + "#, + r#" + enum A { One, Two, } + fn foo(a: A) { + match <|>a { + A::One => {} + A::Two => {} + } + } + "#, + ); + } } -- cgit v1.2.3