1
Fork 0

replace_tabs -> normalize_whitespace

This commit is contained in:
Esteban Kuber 2021-09-10 07:32:07 +00:00
parent d68add9ecc
commit 143f784199

View file

@ -730,7 +730,7 @@ impl EmitterWriter {
} }
let source_string = match file.get_line(line.line_index - 1) { let source_string = match file.get_line(line.line_index - 1) {
Some(s) => replace_tabs(&*s), Some(s) => normalize_whitespace(&*s),
None => return Vec::new(), None => return Vec::new(),
}; };
@ -1286,7 +1286,7 @@ impl EmitterWriter {
} }
for &(ref text, _) in msg.iter() { for &(ref text, _) in msg.iter() {
// Account for newlines to align output to its label. // Account for newlines to align output to its label.
for (line, text) in replace_tabs(text).lines().enumerate() { for (line, text) in normalize_whitespace(text).lines().enumerate() {
buffer.append( buffer.append(
0 + line, 0 + line,
&format!( &format!(
@ -1550,7 +1550,7 @@ impl EmitterWriter {
self.draw_line( self.draw_line(
&mut buffer, &mut buffer,
&replace_tabs(&unannotated_line), &normalize_whitespace(&unannotated_line),
annotated_file.lines[line_idx + 1].line_index - 1, annotated_file.lines[line_idx + 1].line_index - 1,
last_buffer_line_num, last_buffer_line_num,
width_offset, width_offset,
@ -1672,7 +1672,7 @@ impl EmitterWriter {
buffer.puts( buffer.puts(
row_num - 1, row_num - 1,
max_line_num_len + 3, max_line_num_len + 3,
&replace_tabs( &normalize_whitespace(
&*file_lines &*file_lines
.file .file
.get_line(file_lines.lines[line_pos].line_index) .get_line(file_lines.lines[line_pos].line_index)
@ -1698,7 +1698,7 @@ impl EmitterWriter {
} }
// print the suggestion // print the suggestion
buffer.append(row_num, &replace_tabs(line), Style::NoStyle); buffer.append(row_num, &normalize_whitespace(line), Style::NoStyle);
// Colorize addition/replacements with green. // Colorize addition/replacements with green.
for &SubstitutionHighlight { start, end } in highlight_parts { for &SubstitutionHighlight { start, end } in highlight_parts {
@ -2093,7 +2093,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
('\u{2069}', ""), ('\u{2069}', ""),
]; ];
fn replace_tabs(str: &str) -> String { fn normalize_whitespace(str: &str) -> String {
let mut s = str.to_string(); let mut s = str.to_string();
for (c, replacement) in OUTPUT_REPLACEMENTS { for (c, replacement) in OUTPUT_REPLACEMENTS {
s = s.replace(*c, replacement); s = s.replace(*c, replacement);