Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,12 @@ impl EmitterWriter {
code_offset + annotation.start_col,
style);
}
_ => (),
_ => {
buffer.set_style_range(line_offset,
code_offset + annotation.start_col,
code_offset + annotation.end_col,
Style::Highlight);
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/librustc_errors/styled_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,22 @@ impl StyledBuffer {
pub fn num_lines(&self) -> usize {
self.text.len()
}

pub fn set_style_range(&mut self,
line: usize,
col_start: usize,
col_end: usize,
style: Style) {
for col in col_start..col_end {
self.set_style(line, col, style);
}
}

pub fn set_style(&mut self, line: usize, col: usize, style: Style) {
if let Some(ref mut line) = self.styles.get_mut(line) {
if let Some(s) = line.get_mut(col) {
*s = style;
}
}
}
}