Skip to content

Commit 7d77775

Browse files
committed
Insert newline after extracted struct's attributes
1 parent 6669ea8 commit 7d77775

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,14 @@ fn create_struct_def(
275275
// copy attributes from enum
276276
ted::insert_all(
277277
ted::Position::first_child_of(strukt.syntax()),
278-
enum_.attrs().map(|it| it.syntax().clone_for_update().into()).collect(),
278+
enum_
279+
.attrs()
280+
.flat_map(|it| {
281+
vec![it.syntax().clone_for_update().into(), make::tokens::single_newline().into()]
282+
})
283+
.collect(),
279284
);
285+
280286
strukt
281287
}
282288

@@ -458,10 +464,14 @@ enum En<T> { Var(Var<T>) }"#,
458464
fn test_extract_struct_carries_over_attributes() {
459465
check_assist(
460466
extract_struct_from_enum_variant,
461-
r#"#[derive(Debug)]
467+
r#"
468+
#[derive(Debug)]
462469
#[derive(Clone)]
463470
enum Enum { Variant{ field: u32$0 } }"#,
464-
r#"#[derive(Debug)]#[derive(Clone)] struct Variant{ field: u32 }
471+
r#"
472+
#[derive(Debug)]
473+
#[derive(Clone)]
474+
struct Variant{ field: u32 }
465475
466476
#[derive(Debug)]
467477
#[derive(Clone)]

0 commit comments

Comments
 (0)