This repository was archived by the owner on Nov 24, 2023. It is now read-only.
File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -288,13 +288,24 @@ fn apply_suggestion(suggestion: &Suggestion) -> Result<(), ProgramError> {
288
288
. join ( "\n " ) ) ;
289
289
new_content. push_str ( "\n " ) ;
290
290
291
- // TODO(killercup): Replace sections of lines only
292
- new_content. push_str ( & indent ( ( suggestion. line_range . start . column - 1 ) as u32 ,
293
- suggestion. replacement . trim ( ) ) ) ;
291
+ // Parts of line before replacement
292
+ new_content. push_str ( & file_content. lines ( )
293
+ . nth ( suggestion. line_range . start . line - 1 )
294
+ . unwrap_or ( "" )
295
+ . chars ( )
296
+ . take ( suggestion. line_range . start . column - 1 )
297
+ . collect :: < String > ( ) ) ;
294
298
295
- if suggestion. text . trim ( ) . ends_with ( ';' ) && !suggestion. replacement . trim ( ) . ends_with ( ';' ) {
296
- new_content. push_str ( ";" ) ;
297
- }
299
+ // Insert new content! Finally!
300
+ new_content. push_str ( & suggestion. replacement ) ;
301
+
302
+ // Parts of line after replacement
303
+ new_content. push_str ( & file_content. lines ( )
304
+ . nth ( suggestion. line_range . end . line - 1 )
305
+ . unwrap_or ( "" )
306
+ . chars ( )
307
+ . skip ( suggestion. line_range . end . column - 1 )
308
+ . collect :: < String > ( ) ) ;
298
309
299
310
// Add the lines after the section we want to replace
300
311
new_content. push_str ( "\n " ) ;
You can’t perform that action at this time.
0 commit comments