Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Show underlines even when first label has no message#114

Merged
zesterer merged 3 commits intozesterer:mainfrom
narpfel:underlines-for-unlabeled
Nov 27, 2025
Merged

Show underlines even when first label has no message#114
zesterer merged 3 commits intozesterer:mainfrom
narpfel:underlines-for-unlabeled

Conversation

@narpfel
Copy link
Copy Markdown
Contributor

@narpfel narpfel commented Apr 26, 2024

In ariadne v0.3.0, any label would cause its span to be underlined, but also add blank lines to the output even when it had no message.

In v0.4.0, the extraneous blank lines were removed, but the behaviour regarding underlines was also changed: When the first label has no message set, no underlines at all are shown:

    const SOURCE: &str = "a b c d e f";
    // also supports labels with no messages to only emphasis on some areas
    Report::build(ReportKind::Error, (), 34)
        .with_message("Incompatible types")
        .with_label(Label::new(0..1).with_color(Color::Red))
        .with_label(
            Label::new(2..3)
                .with_color(Color::Blue)
                .with_message("`b` for banana")
                .with_order(1),
        )
        .with_label(Label::new(4..5).with_color(Color::Green))
        .with_label(
            Label::new(7..9)
                .with_color(Color::Cyan)
                .with_message("`e` for emerald"),
        )
        .finish()
        .print(Source::from(SOURCE))
        .unwrap();

(Based on examples/simple.rs without compact.)

This will show

Error: Incompatible types
   ╭─[<unknown>:?:?]
   │
 1 │ a b c d e f
   │   │     │
   │   │     ╰── `e` for emerald
   │   │
   │   ╰──────── `b` for banana
───╯

But when the first label for a has a message, all spans have underlines:

Error: Incompatible types
   ╭─[<unknown>:?:?]
   │
 1 │ a b c d e f
   │ ┬ ┬ ─  ─┬
   │ ╰────────── a
   │   │     │
   │   │     ╰── `e` for emerald
   │   │
   │   ╰──────── `b` for banana
───╯

With this PR, underlines will be shown regardless of whether the first label has a message:

Error: Incompatible types
   ╭─[<unknown>:?:?]
   │
 1 │ a b c d e f
   │ ─ ┬ ─  ─┬
   │   │     │
   │   │     ╰── `e` for emerald
   │   │
   │   ╰──────── `b` for banana
───╯

@zesterer
Copy link
Copy Markdown
Owner

Thanks, this seems like a sensible change! I'll try to find some time to review this over the next day or two, I'm not sure I can assure myself of its correctness at just a glance.

@narpfel narpfel force-pushed the underlines-for-unlabeled branch from a9cb338 to 47acc5b Compare November 20, 2025 21:07
@narpfel
Copy link
Copy Markdown
Contributor Author

narpfel commented Nov 20, 2025

Resolved merge conflicts and rebased onto current main.

@zesterer
Copy link
Copy Markdown
Owner

Thanks! Looks like there's a failure in the tests now though.

@narpfel
Copy link
Copy Markdown
Contributor Author

narpfel commented Nov 21, 2025

The test failure is independent of this change: It also occurs on main. I think it’s caused by a change in yesterday’s release of insta 1.44.0, mitsuhiko/insta#563, specifically this change https://github.com/mitsuhiko/insta/pull/563/files#diff-2666420e8389f1d842ce108018b05f3f68fa4b920f8c1793a3d4d01f21443544R868-R870 (link that actually works) that leading indentation is no longer removed in single-line snapshots.

@zesterer
Copy link
Copy Markdown
Owner

Thanks so much for the PR, sorry it took so long to get merged!

@zesterer zesterer merged commit 4ebd26d into zesterer:main Nov 27, 2025
3 checks passed
@narpfel narpfel deleted the underlines-for-unlabeled branch November 28, 2025 18:55
@narpfel
Copy link
Copy Markdown
Contributor Author

narpfel commented Nov 28, 2025

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants