Skip to content

Commit

Permalink
Add fix for tabs. Move error unit tests->ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Turner committed Jul 14, 2016
1 parent 2e8e73c commit 1fd014a
Show file tree
Hide file tree
Showing 17 changed files with 414 additions and 772 deletions.
25 changes: 19 additions & 6 deletions src/librustc_errors/styled_buffer.rs
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1fd014a

Please sign in to comment.