Skip to content

Commit

Permalink
fix: Fix bug in origin location computation
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelPeeters committed Oct 20, 2024
1 parent 15e503f commit 695e428
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/renderer/display_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ fn format_header<'a>(
..
} = item
{
if main_range >= range.0 && main_range <= range.1 + end_line.len() {
if main_range >= range.0 && main_range < range.1 + max(*end_line as usize, 1) {
let char_column = text[0..(main_range - range.0).min(text.len())]
.chars()
.count();
Expand Down
2 changes: 1 addition & 1 deletion tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ fn origin_correct_start_line() {

let expected = str![[r#"
error: title
--> origin.txt:2:4
--> origin.txt:3:1
|
1 | aaa
2 | bbb
Expand Down

0 comments on commit 695e428

Please sign in to comment.