From 638d0bde10b0c2e75bd445c2ed6d32c598408d19 Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Fri, 6 Feb 2026 12:59:09 +0100 Subject: [PATCH] test: add regression test for multiline labels --- tests/graphical.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/graphical.rs b/tests/graphical.rs index 93c9bce..8a05ac3 100644 --- a/tests/graphical.rs +++ b/tests/graphical.rs @@ -489,6 +489,54 @@ if true { assert_eq!(expected, out); } +#[test] +fn multiline_span_end_same_line_as_singleline() { + #[derive(Error, Debug, Diagnostic)] + #[error("oops!")] + #[diagnostic(severity(Error))] + struct MyBad { + #[source_code] + src: NamedSource<&'static str>, + #[label("multiline label")] + multiline: SourceSpan, + #[label("singleline label")] + singleline: SourceSpan, + } + let src = "\ + function test( + bool a, + ) internal returns (uint256 helloWorld, Test someTest) { + // oh hai + } +"; + let err = MyBad { + src: NamedSource::new("issue", src), + // multiline span from "function" to end of ")" + multiline: (0, 38).into(), + // singleline span on "uint256 helloWorld" + singleline: (55, 18).into(), + }; + let out = fmt_report(err.into()); + println!("Error: {}", out); + + // The │ should continue on the underline and label lines until the multiline span's + // own label is rendered with ╰──── + let expected = r#" + × oops! + ╭─[issue:1:1] + 1 │ ╭─▶ function test( + 2 │ │ bool a, + 3 │ ├─▶ ) internal returns (uint256 helloWorld, Test someTest) { + · │ ─────────┬──────── + · │ ╰── singleline label + · ╰──── multiline label + 4 │ // oh hai + ╰──── +"# + .trim_start_matches('\n'); + assert_eq!(expected, out); +} + #[test] fn single_line_highlight_span_full_line() { #[derive(Error, Debug, Diagnostic)]