@@ -1623,7 +1623,7 @@ impl EmitterWriter {
1623
1623
let line_start = sm. lookup_char_pos ( parts[ 0 ] . span . lo ( ) ) . line ;
1624
1624
draw_col_separator_no_space ( & mut buffer, 1 , max_line_num_len + 1 ) ;
1625
1625
let mut lines = complete. lines ( ) ;
1626
- for ( line_pos, ( line, parts ) ) in
1626
+ for ( line_pos, ( line, highlight_parts ) ) in
1627
1627
lines. by_ref ( ) . zip ( highlights) . take ( MAX_SUGGESTION_HIGHLIGHT_LINES ) . enumerate ( )
1628
1628
{
1629
1629
// Print the span column to avoid confusion
@@ -1658,7 +1658,7 @@ impl EmitterWriter {
1658
1658
) ;
1659
1659
buffer. puts ( row_num, max_line_num_len + 1 , "+ " , Style :: Addition ) ;
1660
1660
} else if is_multiline {
1661
- match & parts [ ..] {
1661
+ match & highlight_parts [ ..] {
1662
1662
[ SubstitutionHighlight { start : 0 , end } ] if * end == line. len ( ) => {
1663
1663
buffer. puts ( row_num, max_line_num_len + 1 , "+ " , Style :: Addition ) ;
1664
1664
}
@@ -1676,16 +1676,24 @@ impl EmitterWriter {
1676
1676
// print the suggestion
1677
1677
buffer. append ( row_num, & replace_tabs ( line) , Style :: NoStyle ) ;
1678
1678
1679
- if is_multiline {
1680
- for SubstitutionHighlight { start, end } in parts {
1681
- buffer. set_style_range (
1682
- row_num,
1683
- max_line_num_len + 3 + start,
1684
- max_line_num_len + 3 + end,
1685
- Style :: Addition ,
1686
- true ,
1687
- ) ;
1688
- }
1679
+ // Colorize addition/replacements with green.
1680
+ for & SubstitutionHighlight { start, end } in highlight_parts {
1681
+ // Account for tabs when highlighting (#87972).
1682
+ let tabs: usize = line
1683
+ . chars ( )
1684
+ . take ( start)
1685
+ . map ( |ch| match ch {
1686
+ '\t' => 3 ,
1687
+ _ => 0 ,
1688
+ } )
1689
+ . sum ( ) ;
1690
+ buffer. set_style_range (
1691
+ row_num,
1692
+ max_line_num_len + 3 + start + tabs,
1693
+ max_line_num_len + 3 + end + tabs,
1694
+ Style :: Addition ,
1695
+ true ,
1696
+ ) ;
1689
1697
}
1690
1698
row_num += 1 ;
1691
1699
}
@@ -1723,13 +1731,6 @@ impl EmitterWriter {
1723
1731
assert ! ( underline_start >= 0 && underline_end >= 0 ) ;
1724
1732
let padding: usize = max_line_num_len + 3 ;
1725
1733
for p in underline_start..underline_end {
1726
- // Colorize addition/replacements with green.
1727
- buffer. set_style (
1728
- row_num - 1 ,
1729
- ( padding as isize + p) as usize ,
1730
- Style :: Addition ,
1731
- true ,
1732
- ) ;
1733
1734
if !show_diff {
1734
1735
// If this is a replacement, underline with `^`, if this is an addition
1735
1736
// underline with `+`.
0 commit comments