Skip to content

Commit 5bdb9ba

Browse files
committed
fix: Show full line when patch span is points to line end
1 parent 5b47140 commit 5bdb9ba

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/renderer/source_map.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ impl<'a> SourceMap<'a> {
130130
}
131131
lines.push(line_info);
132132
}
133+
134+
if lines.is_empty() && !self.lines.is_empty() {
135+
lines.push(self.lines.last().unwrap());
136+
}
137+
133138
lines
134139
}
135140

tests/formatter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,8 +3639,8 @@ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
36393639
|
36403640
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
36413641
|
3642-
3 | // Span after line end
3643-
|
3642+
3 | [1, 2, 3].into_iter().for_each(|n| { *n; }); // Span after line end
3643+
| ++++++++++++++++++++++
36443644
"#]];
36453645
let renderer = Renderer::plain();
36463646
assert_data_eq!(renderer.render(input), expected_ascii);
@@ -3662,8 +3662,8 @@ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
36623662
╰╴
36633663
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
36643664
╭╴
3665-
3 │ // Span after line end
3666-
╰╴
3665+
3 │ [1, 2, 3].into_iter().for_each(|n| { *n; }); // Span after line end
3666+
╰╴ ++++++++++++++++++++++
36673667
"#]];
36683668
let renderer = renderer.decor_style(DecorStyle::Unicode);
36693669
assert_data_eq!(renderer.render(input), expected_unicode);

0 commit comments

Comments
 (0)