Skip to content

Commit c386813

Browse files
authored
Merge pull request #310 from epage/multi
fix(render): Removing implicit padding with report starting with secondary title
2 parents d38b08b + 2c36f34 commit c386813

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/renderer/render.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ pub(crate) fn render(renderer: &Renderer, groups: Report<'_>) -> String {
8989
max_line_num_len + 1,
9090
);
9191
}
92-
if peek.is_none() && g == 0 && group_len > 1 {
92+
if peek.is_none()
93+
&& title_style == TitleStyle::MainHeader
94+
&& g == 0
95+
&& group_len > 1
96+
{
9397
draw_col_separator_end(
9498
renderer,
9599
&mut buffer,

tests/formatter.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,56 @@ error:
315315
assert_data_eq!(renderer.render(input), expected_unicode);
316316
}
317317

318+
#[test]
319+
fn test_multi_group_no_snippet() {
320+
let input = &[
321+
Group::with_title(Level::ERROR.primary_title("the core problem")),
322+
Group::with_title(Level::NOTE.secondary_title("more information")),
323+
Group::with_title(Level::HELP.secondary_title("a way to fix this")),
324+
];
325+
let expected_ascii = str![[r#"
326+
error: the core problem
327+
|
328+
note: more information
329+
help: a way to fix this
330+
"#]];
331+
let renderer = Renderer::plain();
332+
assert_data_eq!(renderer.render(input), expected_ascii);
333+
334+
let expected_unicode = str![[r#"
335+
error: the core problem
336+
╰╴
337+
note: more information
338+
help: a way to fix this
339+
"#]];
340+
let renderer = renderer.decor_style(DecorStyle::Unicode);
341+
assert_data_eq!(renderer.render(input), expected_unicode);
342+
}
343+
344+
#[test]
345+
fn test_multi_secondary_group_no_snippet() {
346+
let input = &[
347+
Group::with_title(Level::ERROR.secondary_title("the core problem")),
348+
Group::with_title(Level::NOTE.secondary_title("more information")),
349+
Group::with_title(Level::HELP.secondary_title("a way to fix this")),
350+
];
351+
let expected_ascii = str![[r#"
352+
error: the core problem
353+
note: more information
354+
help: a way to fix this
355+
"#]];
356+
let renderer = Renderer::plain();
357+
assert_data_eq!(renderer.render(input), expected_ascii);
358+
359+
let expected_unicode = str![[r#"
360+
error: the core problem
361+
note: more information
362+
help: a way to fix this
363+
"#]];
364+
let renderer = renderer.decor_style(DecorStyle::Unicode);
365+
assert_data_eq!(renderer.render(input), expected_unicode);
366+
}
367+
318368
#[test]
319369
#[should_panic]
320370
fn test_i26() {

0 commit comments

Comments
 (0)