@@ -730,7 +730,7 @@ impl EmitterWriter {
730730 }
731731
732732 let source_string = match file. get_line ( line. line_index - 1 ) {
733- Some ( s) => replace_tabs ( & * s) ,
733+ Some ( s) => normalize_whitespace ( & * s) ,
734734 None => return Vec :: new ( ) ,
735735 } ;
736736
@@ -1286,7 +1286,7 @@ impl EmitterWriter {
12861286 }
12871287 for & ( ref text, _) in msg. iter ( ) {
12881288 // 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 ( ) {
12901290 buffer. append (
12911291 0 + line,
12921292 & format ! (
@@ -1550,7 +1550,7 @@ impl EmitterWriter {
15501550
15511551 self . draw_line (
15521552 & mut buffer,
1553- & replace_tabs ( & unannotated_line) ,
1553+ & normalize_whitespace ( & unannotated_line) ,
15541554 annotated_file. lines [ line_idx + 1 ] . line_index - 1 ,
15551555 last_buffer_line_num,
15561556 width_offset,
@@ -1672,7 +1672,7 @@ impl EmitterWriter {
16721672 buffer. puts (
16731673 row_num - 1 ,
16741674 max_line_num_len + 3 ,
1675- & replace_tabs (
1675+ & normalize_whitespace (
16761676 & * file_lines
16771677 . file
16781678 . get_line ( file_lines. lines [ line_pos] . line_index )
@@ -1698,7 +1698,7 @@ impl EmitterWriter {
16981698 }
16991699
17001700 // print the suggestion
1701- buffer. append ( row_num, & replace_tabs ( line) , Style :: NoStyle ) ;
1701+ buffer. append ( row_num, & normalize_whitespace ( line) , Style :: NoStyle ) ;
17021702
17031703 // Colorize addition/replacements with green.
17041704 for & SubstitutionHighlight { start, end } in highlight_parts {
@@ -2081,6 +2081,7 @@ fn num_decimal_digits(num: usize) -> usize {
20812081// We replace some characters so the CLI output is always consistent and underlines aligned.
20822082const OUTPUT_REPLACEMENTS : & [ ( char , & str ) ] = & [
20832083 ( '\t' , " " ) , // We do our own tab replacement
2084+ ( '\u{200D}' , "" ) , // Replace ZWJ with nothing for consistent terminal output of grapheme clusters.
20842085 ( '\u{202A}' , "" ) , // The following unicode text flow control characters are inconsistently
20852086 ( '\u{202B}' , "" ) , // supported accross CLIs and can cause confusion due to the bytes on disk
20862087 ( '\u{202D}' , "" ) , // not corresponding to the visible source code, so we replace them always.
@@ -2092,7 +2093,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
20922093 ( '\u{2069}' , "" ) ,
20932094] ;
20942095
2095- fn replace_tabs ( str : & str ) -> String {
2096+ fn normalize_whitespace ( str : & str ) -> String {
20962097 let mut s = str. to_string ( ) ;
20972098 for ( c, replacement) in OUTPUT_REPLACEMENTS {
20982099 s = s. replace ( * c, replacement) ;
0 commit comments