@@ -730,7 +730,7 @@ impl EmitterWriter {
730
730
}
731
731
732
732
let source_string = match file. get_line ( line. line_index - 1 ) {
733
- Some ( s) => replace_tabs ( & * s) ,
733
+ Some ( s) => normalize_whitespace ( & * s) ,
734
734
None => return Vec :: new ( ) ,
735
735
} ;
736
736
@@ -1286,7 +1286,7 @@ impl EmitterWriter {
1286
1286
}
1287
1287
for & ( ref text, _) in msg. iter ( ) {
1288
1288
// Account for newlines to align output to its label.
1289
- for ( line, text) in replace_tabs ( text) . lines ( ) . enumerate ( ) {
1289
+ for ( line, text) in normalize_whitespace ( text) . lines ( ) . enumerate ( ) {
1290
1290
buffer. append (
1291
1291
0 + line,
1292
1292
& format ! (
@@ -1550,7 +1550,7 @@ impl EmitterWriter {
1550
1550
1551
1551
self . draw_line (
1552
1552
& mut buffer,
1553
- & replace_tabs ( & unannotated_line) ,
1553
+ & normalize_whitespace ( & unannotated_line) ,
1554
1554
annotated_file. lines [ line_idx + 1 ] . line_index - 1 ,
1555
1555
last_buffer_line_num,
1556
1556
width_offset,
@@ -1672,7 +1672,7 @@ impl EmitterWriter {
1672
1672
buffer. puts (
1673
1673
row_num - 1 ,
1674
1674
max_line_num_len + 3 ,
1675
- & replace_tabs (
1675
+ & normalize_whitespace (
1676
1676
& * file_lines
1677
1677
. file
1678
1678
. get_line ( file_lines. lines [ line_pos] . line_index )
@@ -1698,7 +1698,7 @@ impl EmitterWriter {
1698
1698
}
1699
1699
1700
1700
// print the suggestion
1701
- buffer. append ( row_num, & replace_tabs ( line) , Style :: NoStyle ) ;
1701
+ buffer. append ( row_num, & normalize_whitespace ( line) , Style :: NoStyle ) ;
1702
1702
1703
1703
// Colorize addition/replacements with green.
1704
1704
for & SubstitutionHighlight { start, end } in highlight_parts {
@@ -2081,6 +2081,7 @@ fn num_decimal_digits(num: usize) -> usize {
2081
2081
// We replace some characters so the CLI output is always consistent and underlines aligned.
2082
2082
const OUTPUT_REPLACEMENTS : & [ ( char , & str ) ] = & [
2083
2083
( '\t' , " " ) , // We do our own tab replacement
2084
+ ( '\u{200D}' , "" ) , // Replace ZWJ with nothing for consistent terminal output of grapheme clusters.
2084
2085
( '\u{202A}' , "" ) , // The following unicode text flow control characters are inconsistently
2085
2086
( '\u{202B}' , "" ) , // supported accross CLIs and can cause confusion due to the bytes on disk
2086
2087
( '\u{202D}' , "" ) , // not corresponding to the visible source code, so we replace them always.
@@ -2092,7 +2093,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
2092
2093
( '\u{2069}' , "" ) ,
2093
2094
] ;
2094
2095
2095
- fn replace_tabs ( str : & str ) -> String {
2096
+ fn normalize_whitespace ( str : & str ) -> String {
2096
2097
let mut s = str. to_string ( ) ;
2097
2098
for ( c, replacement) in OUTPUT_REPLACEMENTS {
2098
2099
s = s. replace ( * c, replacement) ;
0 commit comments