Reformatting a URL resulting in `(link)` not moving
Closed this issue · 4 comments
PR where we're running into this: vercel/turborepo#8492
Specifically, we're trying to move the URL diagnostic to the bottom, but the (link)
isn't coming down to format with the text output that's been moved.
Caveat: It's possible that I'm holding it wrong and not realizing it. I'm fairly new to Rust. I asked one of my teammates who is very Rustacean for help, though, and they weren't able to sort things out. It's entirely possible that this works and we weren't able to glean it from the documentation.
The code generating that is https://github.com/zkat/miette/blob/main/src/handlers/graphical.rs#L252-L268
I don't see an error code in your message: I think this is probably happening because you're not setting an error code, which miette kind of expects.
For example, in your case I would use #[diagnostic(code("invalid-env-prefix"), url("https://turbo.build/messages/invalid-env-prefix))]
and that should do what you want?
ah, looking at your PR, yeah, I would just remove the url(...)
from the diagnostic definition, if your entire purpose is to move things down into the help area.
If you want to then linkify that link yourself, you can just grab https://github.com/zkat/miette/blob/main/src/handlers/graphical.rs#L260-L264 to generate a terminal link, and use https://docs.rs/supports-hyperlinks/latest/supports_hyperlinks/ for detecting hyperlink support.
Sounds great and thank you for the help! Will give that a go.
Sorry for bringing in a non-issue! 😄 Will close.
No problem. Hopefully that's all it was. And don't worry about it: a footgun is a footgun. Sorry for the trouble it caused!