@@ -78,26 +78,24 @@ fn add_missing_impl_members_inner(
7878
7979 ctx. add_action ( AssistId ( assist_id) , label, |edit| {
8080 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 ( ) {
8884 ImplItemKind :: FnDef ( def) => {
8985 strip_docstring ( ImplItem :: cast ( add_body ( def) . syntax ( ) ) . unwrap ( ) )
9086 }
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) ) ;
9593
9694 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 ( ) ;
9896 ast_editor. into_text_edit ( edit. text_edit_builder ( ) ) ;
9997
100- edit. set_cursor ( cursor_poisition ) ;
98+ edit. set_cursor ( cursor_position ) ;
10199 } ) ;
102100
103101 ctx. build ( )
0 commit comments