@@ -177,48 +177,6 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(diagnostic: &Diagnostic,
177
177
}
178
178
}
179
179
180
- pub fn apply_suggestion ( file_content : & mut String , suggestion : & Replacement ) -> String {
181
- use std:: cmp:: max;
182
-
183
- let mut new_content = String :: new ( ) ;
184
-
185
- // Add the lines before the section we want to replace
186
- new_content. push_str ( & file_content. lines ( )
187
- . take ( max ( suggestion. snippet . line_range . start . line - 1 , 0 ) as usize )
188
- . collect :: < Vec < _ > > ( )
189
- . join ( "\n " ) ) ;
190
- new_content. push_str ( "\n " ) ;
191
-
192
- // Parts of line before replacement
193
- new_content. push_str ( & file_content. lines ( )
194
- . nth ( suggestion. snippet . line_range . start . line - 1 )
195
- . unwrap_or ( "" )
196
- . chars ( )
197
- . take ( suggestion. snippet . line_range . start . column - 1 )
198
- . collect :: < String > ( ) ) ;
199
-
200
- // Insert new content! Finally!
201
- new_content. push_str ( & suggestion. replacement ) ;
202
-
203
- // Parts of line after replacement
204
- new_content. push_str ( & file_content. lines ( )
205
- . nth ( suggestion. snippet . line_range . end . line - 1 )
206
- . unwrap_or ( "" )
207
- . chars ( )
208
- . skip ( suggestion. snippet . line_range . end . column - 1 )
209
- . collect :: < String > ( ) ) ;
210
-
211
- // Add the lines after the section we want to replace
212
- new_content. push_str ( "\n " ) ;
213
- new_content. push_str ( & file_content. lines ( )
214
- . skip ( suggestion. snippet . line_range . end . line as usize )
215
- . collect :: < Vec < _ > > ( )
216
- . join ( "\n " ) ) ;
217
- new_content. push_str ( "\n " ) ;
218
-
219
- new_content
220
- }
221
-
222
180
pub fn apply_suggestions ( code : & str , suggestions : & [ Suggestion ] ) -> Result < String , Error > {
223
181
use replace:: Data ;
224
182
0 commit comments