Skip to content

Commit 943631b

Browse files
committed
Fix single char overflow display issue
Fixes the error described in rust-lang#16. Previously, when a single character of an annotation overflows to a new line, the DisplayList would incorrectly consider that character on the same line. This change fixes this and adds a new fixture test for this case.
1 parent 435da66 commit 943631b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/display_list/from_snippet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn format_body(slice: &snippet::Slice, has_footer: bool) -> Vec<DisplayLine> {
214214
};
215215
match annotation.range {
216216
(start, _) if start > line_end => true,
217-
(start, end) if start >= line_start && end <= line_end + 1 => {
217+
(start, end) if start >= line_start && end <= line_end => {
218218
let range = (start - line_start, end - line_start);
219219
body.insert(
220220
body_idx + 1,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E####]: spacing error found
2+
--> foo.txt:26:12
3+
|
4+
26 | This is an exampl
5+
| ____________^
6+
27 | | e of an edge case of an annotation overflowing
7+
| |_^ this should not be on separate lines
8+
28 | to exactly one character on next line.
9+
|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
slices:
2+
- source: |-
3+
This is an exampl
4+
e of an edge case of an annotation overflowing
5+
to exactly one character on next line.
6+
line_start: 26
7+
origin: foo.txt
8+
fold: false
9+
annotations:
10+
- label: this should not be on separate lines
11+
annotation_type: Error
12+
range: [11, 19]
13+
title:
14+
label: spacing error found
15+
id: E####
16+
annotation_type: Error

0 commit comments

Comments
 (0)