@@ -721,7 +721,7 @@ impl EmitterWriter {
721
721
}
722
722
723
723
let source_string = match file. get_line ( line. line_index - 1 ) {
724
- Some ( s) => replace_tabs ( & * s) ,
724
+ Some ( s) => normalize_whitespace ( & * s) ,
725
725
None => return Vec :: new ( ) ,
726
726
} ;
727
727
@@ -1272,7 +1272,7 @@ impl EmitterWriter {
1272
1272
buffer. append ( 0 , ": " , header_style) ;
1273
1273
}
1274
1274
for & ( ref text, _) in msg. iter ( ) {
1275
- buffer. append ( 0 , & replace_tabs ( text) , header_style) ;
1275
+ buffer. append ( 0 , & normalize_whitespace ( text) , header_style) ;
1276
1276
}
1277
1277
}
1278
1278
@@ -1526,7 +1526,7 @@ impl EmitterWriter {
1526
1526
1527
1527
self . draw_line (
1528
1528
& mut buffer,
1529
- & replace_tabs ( & unannotated_line) ,
1529
+ & normalize_whitespace ( & unannotated_line) ,
1530
1530
annotated_file. lines [ line_idx + 1 ] . line_index - 1 ,
1531
1531
last_buffer_line_num,
1532
1532
width_offset,
@@ -1648,7 +1648,7 @@ impl EmitterWriter {
1648
1648
buffer. puts (
1649
1649
row_num - 1 ,
1650
1650
max_line_num_len + 3 ,
1651
- & replace_tabs (
1651
+ & normalize_whitespace (
1652
1652
& * file_lines
1653
1653
. file
1654
1654
. get_line ( file_lines. lines [ line_pos] . line_index )
@@ -1674,7 +1674,7 @@ impl EmitterWriter {
1674
1674
}
1675
1675
1676
1676
// print the suggestion
1677
- buffer. append ( row_num, & replace_tabs ( line) , Style :: NoStyle ) ;
1677
+ buffer. append ( row_num, & normalize_whitespace ( line) , Style :: NoStyle ) ;
1678
1678
1679
1679
// Colorize addition/replacements with green.
1680
1680
for & SubstitutionHighlight { start, end } in highlight_parts {
@@ -2054,8 +2054,17 @@ fn num_decimal_digits(num: usize) -> usize {
2054
2054
MAX_DIGITS
2055
2055
}
2056
2056
2057
- fn replace_tabs ( str : & str ) -> String {
2058
- str. replace ( '\t' , " " )
2057
+ const REPLACEMENTS : & [ ( char , & str ) ] = & [
2058
+ ( '\t' , " " ) ,
2059
+ ( '\u{200D}' , "" ) , // Replace ZWJ with nothing for consistent terminal output of grapheme clusters.
2060
+ ] ;
2061
+
2062
+ fn normalize_whitespace ( str : & str ) -> String {
2063
+ let mut output = str. to_string ( ) ;
2064
+ for ( c, replacement) in REPLACEMENTS {
2065
+ output = output. replace ( * c, replacement) ;
2066
+ }
2067
+ output
2059
2068
}
2060
2069
2061
2070
fn draw_col_separator ( buffer : & mut StyledBuffer , line : usize , col : usize ) {
0 commit comments