This repository was archived by the owner on Nov 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,6 @@ fn indent(size: u32, s: &str) -> String {
277277/// reverse order to not mess up the lines for replacements further down the road.
278278fn apply_suggestion ( suggestion : & Suggestion ) -> Result < ( ) , ProgramError > {
279279 use std:: cmp:: max;
280- use std:: iter:: repeat;
281280
282281 let file_content = try!( read_file_to_string ( & suggestion. file_name ) ) ;
283282 let mut new_content = String :: new ( ) ;
@@ -287,20 +286,13 @@ fn apply_suggestion(suggestion: &Suggestion) -> Result<(), ProgramError> {
287286 . take ( max ( suggestion. line_range . start . line - 1 , 0 ) as usize )
288287 . collect :: < Vec < _ > > ( )
289288 . join ( "\n " ) ) ;
290-
291- // Some suggestions seem to currently omit the trailing semicolon
292- let remember_a_semicolon = suggestion. text . trim ( ) . ends_with ( ';' ) ;
293-
294- // Indentation
295289 new_content. push_str ( "\n " ) ;
296- new_content. push_str ( & repeat ( " " )
297- . take ( suggestion. line_range . start . column - 1 as usize )
298- . collect :: < String > ( ) ) ;
299290
300291 // TODO(killercup): Replace sections of lines only
301- new_content. push_str ( suggestion. replacement . trim ( ) ) ;
292+ new_content. push_str ( & indent ( ( suggestion. line_range . start . column - 1 ) as u32 ,
293+ suggestion. replacement . trim ( ) ) ) ;
302294
303- if remember_a_semicolon {
295+ if suggestion . text . trim ( ) . ends_with ( ';' ) && !suggestion . replacement . trim ( ) . ends_with ( ';' ) {
304296 new_content. push_str ( ";" ) ;
305297 }
306298
You can’t perform that action at this time.
0 commit comments