Skip to content

Commit a0e10a8

Browse files
authored
Merge pull request #42 from digama0/patch-1
fix off by one error in multiline highlighting
2 parents 46c5588 + 34df93e commit a0e10a8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Diff for: src/display_list/from_snippet.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,10 @@ fn format_body(
427427
});
428428
}
429429

430+
let end_mark = (end - line_start).saturating_sub(1);
430431
let range = (
431-
(end - line_start) - margin_left,
432-
(end - line_start + 1) - margin_left,
432+
end_mark - margin_left,
433+
(end_mark + 1) - margin_left,
433434
);
434435
body.insert(
435436
body_idx + 1,

Diff for: tests/fixtures/no-color/multiline_annotation.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ range = [5, 19]
3333
[[slices.annotations]]
3434
label = "expected enum `std::option::Option`, found ()"
3535
annotation_type = "Error"
36-
range = [22, 765]
36+
range = [22, 766]
3737
[title]
3838
label = "mismatched types"
3939
id = "E0308"

Diff for: tests/fixtures/no-color/multiline_annotation2.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fold = false
1010
[[slices.annotations]]
1111
label = "missing fields `lineno`, `content`"
1212
annotation_type = "Error"
13-
range = [31, 127]
13+
range = [31, 128]
1414

1515
[title]
1616
label = "pattern does not mention fields `lineno`, `content`"

0 commit comments

Comments
 (0)