@@ -388,6 +388,11 @@ impl CodeSuggestion {
388388                    "all spans must be disjoint" , 
389389                ) ; 
390390
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+ 
391396                // Find the bounding span. 
392397                let  lo = substitution. parts . iter ( ) . map ( |part| part. span . lo ( ) ) . min ( ) ?; 
393398                let  hi = substitution. parts . iter ( ) . map ( |part| part. span . hi ( ) ) . max ( ) ?; 
@@ -476,16 +481,12 @@ impl CodeSuggestion {
476481                            _ => 1 , 
477482                        } ) 
478483                        . 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+ 
489490                    buf. push_str ( & part. snippet ) ; 
490491                    let  cur_hi = sm. lookup_char_pos ( part. span . hi ( ) ) ; 
491492                    // Account for the difference between the width of the current code and the 
0 commit comments