fix(reporter): Only inc the line count if we haven't already done so with '\n' or '\r\n' (#37)

This commit is contained in:
Felipe Seré 2021-08-29 19:33:45 +00:00 committed by GitHub
parent 53f5d6d1d6
commit 5a474370dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -461,6 +461,7 @@ impl GraphicalReportPrinter {
let mut lines = Vec::new();
while let Some(char) = iter.next() {
offset += char.len_utf8();
let mut at_end_of_file = false;
match char {
'\r' => {
if iter.next_if_eq(&'\n').is_some() {
@ -471,8 +472,10 @@ impl GraphicalReportPrinter {
line_str.push(char);
column += 1;
}
at_end_of_file = iter.peek().is_none();
}
'\n' => {
at_end_of_file = iter.peek().is_none();
line += 1;
column = 0;
}
@ -481,7 +484,8 @@ impl GraphicalReportPrinter {
column += 1;
}
}
if iter.peek().is_none() {
if iter.peek().is_none() && !at_end_of_file {
line += 1;
}

View File

@ -277,7 +277,7 @@ line5
3 line3
4 line4
· block 2
6 line5
5 line5
· block 1
try doing it better next time?
@ -329,7 +329,7 @@ line5
2 line2
3 line3
4 line4
6 line5
5 line5
· block 1
try doing it better next time?