fix lines
This commit is contained in:
parent
d9fc775d56
commit
795e67c984
|
@ -50,7 +50,7 @@ impl Emitter for PrettyEmitter {
|
||||||
let line_hdr_padding = line.to_string().len() + 1;
|
let line_hdr_padding = line.to_string().len() + 1;
|
||||||
|
|
||||||
writeln!(output, "{}{}", " ".repeat(line_hdr_padding), "|".bright_blue().bold()).unwrap();
|
writeln!(output, "{}{}", " ".repeat(line_hdr_padding), "|".bright_blue().bold()).unwrap();
|
||||||
writeln!(output, "{}{} {} {}", line.to_string().bright_blue().bold(), " ".repeat(line_no_padding - line.to_string().len()), "|".bright_blue().bold(), get_line(line, &source).unwrap_or("<line unavailable>")).unwrap();
|
writeln!(output, "{}{} {} {}", line.to_string().bright_blue().bold(), " ".repeat(line_no_padding - line.to_string().len()), "|".bright_blue().bold(), get_line(line-1, &source).unwrap_or("<line unavailable>")).unwrap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,5 +16,5 @@ pub fn pos_to_line_col(pos: usize, source: &str) -> (usize, usize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_line(line: usize, source: &str) -> Option<&str> {
|
pub fn get_line(line: usize, source: &str) -> Option<&str> {
|
||||||
source.lines().nth(line)
|
source.split('\n').nth(line)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue