This repository was archived by the owner on Nov 24, 2023. It is now read-only.
File tree 1 file changed +3
-11
lines changed
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 {
277
277
/// reverse order to not mess up the lines for replacements further down the road.
278
278
fn apply_suggestion ( suggestion : & Suggestion ) -> Result < ( ) , ProgramError > {
279
279
use std:: cmp:: max;
280
- use std:: iter:: repeat;
281
280
282
281
let file_content = try!( read_file_to_string ( & suggestion. file_name ) ) ;
283
282
let mut new_content = String :: new ( ) ;
@@ -287,20 +286,13 @@ fn apply_suggestion(suggestion: &Suggestion) -> Result<(), ProgramError> {
287
286
. take ( max ( suggestion. line_range . start . line - 1 , 0 ) as usize )
288
287
. collect :: < Vec < _ > > ( )
289
288
. 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
295
289
new_content. push_str ( "\n " ) ;
296
- new_content. push_str ( & repeat ( " " )
297
- . take ( suggestion. line_range . start . column - 1 as usize )
298
- . collect :: < String > ( ) ) ;
299
290
300
291
// 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 ( ) ) ) ;
302
294
303
- if remember_a_semicolon {
295
+ if suggestion . text . trim ( ) . ends_with ( ';' ) && !suggestion . replacement . trim ( ) . ends_with ( ';' ) {
304
296
new_content. push_str ( ";" ) ;
305
297
}
306
298
You can’t perform that action at this time.
0 commit comments