From 867261d74e191bac352f5c1b3f2f9238eee46ee3 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 9 Sep 2025 20:05:04 -0500 Subject: [PATCH 1/2] test: Show multi-group inconsistency --- tests/formatter.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/formatter.rs b/tests/formatter.rs index 87334091..4dd9b3cd 100644 --- a/tests/formatter.rs +++ b/tests/formatter.rs @@ -315,6 +315,58 @@ error: assert_data_eq!(renderer.render(input), expected_unicode); } +#[test] +fn test_multi_group_no_snippet() { + let input = &[ + Group::with_title(Level::ERROR.primary_title("the core problem")), + Group::with_title(Level::NOTE.secondary_title("more information")), + Group::with_title(Level::HELP.secondary_title("a way to fix this")), + ]; + let expected_ascii = str![[r#" +error: the core problem + | +note: more information +help: a way to fix this +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input), expected_ascii); + + let expected_unicode = str![[r#" +error: the core problem + ╰╴ +note: more information +help: a way to fix this +"#]]; + let renderer = renderer.decor_style(DecorStyle::Unicode); + assert_data_eq!(renderer.render(input), expected_unicode); +} + +#[test] +fn test_multi_secondary_group_no_snippet() { + let input = &[ + Group::with_title(Level::ERROR.secondary_title("the core problem")), + Group::with_title(Level::NOTE.secondary_title("more information")), + Group::with_title(Level::HELP.secondary_title("a way to fix this")), + ]; + let expected_ascii = str![[r#" +error: the core problem + | +note: more information +help: a way to fix this +"#]]; + let renderer = Renderer::plain(); + assert_data_eq!(renderer.render(input), expected_ascii); + + let expected_unicode = str![[r#" +error: the core problem + ╰╴ +note: more information +help: a way to fix this +"#]]; + let renderer = renderer.decor_style(DecorStyle::Unicode); + assert_data_eq!(renderer.render(input), expected_unicode); +} + #[test] #[should_panic] fn test_i26() { From 2c36f344e668b986d15b62bdaf6d69956c8fc1c8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 9 Sep 2025 20:33:40 -0500 Subject: [PATCH 2/2] fix(render): No implicit padding with starting secondary groups Workaround for #309 --- src/renderer/render.rs | 6 +++++- tests/formatter.rs | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/render.rs b/src/renderer/render.rs index 042c6e02..e8cb5fa4 100644 --- a/src/renderer/render.rs +++ b/src/renderer/render.rs @@ -89,7 +89,11 @@ pub(crate) fn render(renderer: &Renderer, groups: Report<'_>) -> String { max_line_num_len + 1, ); } - if peek.is_none() && g == 0 && group_len > 1 { + if peek.is_none() + && title_style == TitleStyle::MainHeader + && g == 0 + && group_len > 1 + { draw_col_separator_end( renderer, &mut buffer, diff --git a/tests/formatter.rs b/tests/formatter.rs index 4dd9b3cd..64e96b69 100644 --- a/tests/formatter.rs +++ b/tests/formatter.rs @@ -350,7 +350,6 @@ fn test_multi_secondary_group_no_snippet() { ]; let expected_ascii = str![[r#" error: the core problem - | note: more information help: a way to fix this "#]]; @@ -359,7 +358,6 @@ help: a way to fix this let expected_unicode = str![[r#" error: the core problem - ╰╴ note: more information help: a way to fix this "#]];