fix lines

This commit is contained in:
core 2024-01-17 20:28:13 -05:00
parent d9fc775d56
commit 795e67c984
Signed by: core
GPG Key ID: FDBF740DADDCEECF
2 changed files with 2 additions and 2 deletions

View File

@ -50,7 +50,7 @@ impl Emitter for PrettyEmitter {
let line_hdr_padding = line.to_string().len() + 1;
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();

View File

@ -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> {
source.lines().nth(line)
source.split('\n').nth(line)
}