@@ -388,6 +388,11 @@ impl CodeSuggestion {
388
388
"all spans must be disjoint" ,
389
389
) ;
390
390
391
+ // Account for cases where we are suggesting the same code that's already
392
+ // there. This shouldn't happen often, but in some cases for multipart
393
+ // suggestions it's much easier to handle it here than in the origin.
394
+ substitution. parts . retain ( |p| is_different ( sm, & p. snippet , p. span ) ) ;
395
+
391
396
// Find the bounding span.
392
397
let lo = substitution. parts . iter ( ) . map ( |part| part. span . lo ( ) ) . min ( ) ?;
393
398
let hi = substitution. parts . iter ( ) . map ( |part| part. span . hi ( ) ) . max ( ) ?;
@@ -476,16 +481,12 @@ impl CodeSuggestion {
476
481
_ => 1 ,
477
482
} )
478
483
. sum ( ) ;
479
- if !is_different ( sm, & part. snippet , part. span ) {
480
- // Account for cases where we are suggesting the same code that's already
481
- // there. This shouldn't happen often, but in some cases for multipart
482
- // suggestions it's much easier to handle it here than in the origin.
483
- } else {
484
- line_highlight. push ( SubstitutionHighlight {
485
- start : ( cur_lo. col . 0 as isize + acc) as usize ,
486
- end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
487
- } ) ;
488
- }
484
+
485
+ line_highlight. push ( SubstitutionHighlight {
486
+ start : ( cur_lo. col . 0 as isize + acc) as usize ,
487
+ end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
488
+ } ) ;
489
+
489
490
buf. push_str ( & part. snippet ) ;
490
491
let cur_hi = sm. lookup_char_pos ( part. span . hi ( ) ) ;
491
492
// Account for the difference between the width of the current code and the
0 commit comments