@@ -78,26 +78,24 @@ fn add_missing_impl_members_inner(
78
78
79
79
ctx. add_action ( AssistId ( assist_id) , label, |edit| {
80
80
let n_existing_items = impl_item_list. impl_items ( ) . count ( ) ;
81
- let mut ast_editor = AstEditor :: new ( impl_item_list) ;
82
- if n_existing_items == 0 {
83
- ast_editor. make_multiline ( ) ;
84
- }
85
-
86
- for item in missing_items {
87
- let it = match item. kind ( ) {
81
+ let items: Vec < _ > = missing_items
82
+ . into_iter ( )
83
+ . map ( |it| match it. kind ( ) {
88
84
ImplItemKind :: FnDef ( def) => {
89
85
strip_docstring ( ImplItem :: cast ( add_body ( def) . syntax ( ) ) . unwrap ( ) )
90
86
}
91
- _ => strip_docstring ( item) ,
92
- } ;
93
- ast_editor. append_item ( & it)
94
- }
87
+ _ => strip_docstring ( it) ,
88
+ } )
89
+ . collect ( ) ;
90
+ let mut ast_editor = AstEditor :: new ( impl_item_list) ;
91
+
92
+ ast_editor. append_items ( items. iter ( ) . map ( |it| & * * it) ) ;
95
93
96
94
let first_new_item = ast_editor. ast ( ) . impl_items ( ) . nth ( n_existing_items) . unwrap ( ) ;
97
- let cursor_poisition = first_new_item. syntax ( ) . range ( ) . start ( ) ;
95
+ let cursor_position = first_new_item. syntax ( ) . range ( ) . start ( ) ;
98
96
ast_editor. into_text_edit ( edit. text_edit_builder ( ) ) ;
99
97
100
- edit. set_cursor ( cursor_poisition ) ;
98
+ edit. set_cursor ( cursor_position ) ;
101
99
} ) ;
102
100
103
101
ctx. build ( )
0 commit comments