diff options
Diffstat (limited to 'src/librustc_errors/styled_buffer.rs')
| -rw-r--r-- | src/librustc_errors/styled_buffer.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index 238caf93b83..9768b68619e 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -26,10 +26,27 @@ impl StyledBuffer { } } - pub fn render(&self) -> Vec<Vec<StyledString>> { + pub fn copy_tabs(&mut self, row: usize) { + if row < self.text.len() { + for i in row+1..self.text.len() { + for j in 0..self.text[i].len() { + if self.text[row].len() > j && + self.text[row][j] == '\t' && + self.text[i][j] == ' ' { + self.text[i][j] = '\t'; + } + } + } + } + } + + pub fn render(&mut self) -> Vec<Vec<StyledString>> { let mut output: Vec<Vec<StyledString>> = vec![]; let mut styled_vec: Vec<StyledString> = vec![]; + //before we render, do a little patch-up work to support tabs + self.copy_tabs(3); + for (row, row_style) in self.text.iter().zip(&self.styles) { let mut current_style = Style::NoStyle; let mut current_text = String::new(); @@ -78,11 +95,7 @@ impl StyledBuffer { } else { let mut i = self.text[line].len(); while i < col { - let s = match self.text[0].get(i) { - Some(&'\t') => '\t', - _ => ' ', - }; - self.text[line].push(s); + self.text[line].push(' '); self.styles[line].push(Style::NoStyle); i += 1; } |
