aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists')
-rw-r--r--crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
index 53709e31f..fc5a17f05 100644
--- a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
+++ b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
@@ -97,10 +97,16 @@ fn edit_struct_def(
97 if let Either::Left(strukt) = strukt { 97 if let Either::Left(strukt) = strukt {
98 if let Some(w) = strukt.where_clause() { 98 if let Some(w) = strukt.where_clause() {
99 edit.delete(w.syntax().text_range()); 99 edit.delete(w.syntax().text_range());
100 edit.insert(tuple_fields_text_range.start(), ast::make::tokens::single_newline().text()); 100 edit.insert(
101 tuple_fields_text_range.start(),
102 ast::make::tokens::single_newline().text(),
103 );
101 edit.insert(tuple_fields_text_range.start(), w.syntax().text()); 104 edit.insert(tuple_fields_text_range.start(), w.syntax().text());
102 edit.insert(tuple_fields_text_range.start(), ","); 105 edit.insert(tuple_fields_text_range.start(), ",");
103 edit.insert(tuple_fields_text_range.start(), ast::make::tokens::single_newline().text()); 106 edit.insert(
107 tuple_fields_text_range.start(),
108 ast::make::tokens::single_newline().text(),
109 );
104 } else { 110 } else {
105 edit.insert(tuple_fields_text_range.start(), ast::make::tokens::single_space().text()); 111 edit.insert(tuple_fields_text_range.start(), ast::make::tokens::single_space().text());
106 } 112 }
@@ -534,7 +540,10 @@ where
534 convert_tuple_struct_to_named_struct, 540 convert_tuple_struct_to_named_struct,
535 r#"enum Enum { Variant$0 { value: usize } };"#, 541 r#"enum Enum { Variant$0 { value: usize } };"#,
536 ); 542 );
537 check_assist_not_applicable(convert_tuple_struct_to_named_struct, r#"enum Enum { Variant$0 }"#); 543 check_assist_not_applicable(
544 convert_tuple_struct_to_named_struct,
545 r#"enum Enum { Variant$0 }"#,
546 );
538 } 547 }
539 548
540 #[test] 549 #[test]