diff options
| author | Jonathan Turner <jturner@mozilla.com> | 2016-07-13 17:53:42 -0400 |
|---|---|---|
| committer | Jonathan Turner <jturner@mozilla.com> | 2016-07-14 07:57:46 -0400 |
| commit | 1fd014a9654e11ae1bc7c0793c6b01b157d825cd (patch) | |
| tree | 4216ec70bb7a69c2400685a209cde15ce7bcdd24 /src/librustc_errors | |
| parent | 2e8e73cb951e2095e444c5cc91403f7e9c5f1065 (diff) | |
| download | rust-1fd014a9654e11ae1bc7c0793c6b01b157d825cd.tar.gz rust-1fd014a9654e11ae1bc7c0793c6b01b157d825cd.zip | |
Add fix for tabs. Move error unit tests->ui tests
Diffstat (limited to 'src/librustc_errors')
| -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; } |
