Help text for `rustup update` contains a broken URL when line-broken
Problem
Some terminals (including Windows Terminal) provide a mechanism for opening URLs in the default browser when you Ctrl-click on them. The help text for rustup update contains the URL https://github.com/rust-lang/rustup/wiki/Non-host-toolchains; however, if this gets broken across two lines the resulting URL is https://github.com/rust or https://github.com/rust-, which don't go where they're supposed to.
Steps
- Execute the command
rustup help update.
Possible Solution(s)
No response
Notes
Obviously this requires a sufficiently small terminal window to word-wrap the help text.
Rustup version
rustup 1.24.3 (ce5817a94 2021-05-31)
Installed toolchains
Default host: x86_64-pc-windows-gnu
rustup home: C:\Users\Thomas Winwood\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu (default)
nightly-x86_64-pc-windows-gnu
active toolchain
----------------
stable-x86_64-pc-windows-gnu (default)
rustc 1.57.0 (f1edd0429 2021-11-29)
If this is a bug in Rustup, it would likely be in the markdown linewrapper we have, which is pretty simplistic, however looking through that code I cannot see how it would ever split a link across multiple lines. As such this is almost certainly a bug in the terminal you are using. If I deliberately cause a link to be split across multiple lines in my terminal, it is still correctly identified as a single link.
Is there something we can do to cause Windows terminal to detect the continuation of the link?
I did some additional testing and the line in question is wrapped so as to break the URL regardless of the width of the terminal window, so it's not Windows Terminal at fault.
@ketsuban Fascinating. Let me look again.
Oh, this isn't help text when running the command, you mean --help on the CLI. Hmm
It looks like this is part of the wrap_help feature of clap (the CLI parser we use). We'd need to be certain that turning that off won't result in unpleasant UX for others before we'd consider it. Perhaps the clap authors could chime in on whether or not they could detect URLs and not split the words. This remains "not-rustup` in the sense that it's not our fault per-se, but we could do with some input from clap.
I am able to force the same bad behaviour, so I have filed https://github.com/clap-rs/clap/issues/3222 and we'll see what they say
It looks like this is part of the
wrap_helpfeature ofclap(the CLI parser we use). We'd need to be certain that turning that off won't result in unpleasant UX for others before we'd consider it.
Hi @kinnison, I'm the maintainer of Textwrap, the underlying wrapping library used by Clap. I just created a PR (#3070) to enable the wrap_help feature in Clap. The feature seems to be optional and not enabled by default. That helps with the display of text and without it, I find that the help texts look odd. Clap stopped wrapping URLs after https://github.com/clap-rs/clap/pull/3692.
Clap stopped wrapping URLs after clap-rs/clap#3692.
I just checked the Clap changelog and this fix was released in Clap 3.1.16. Rustup is using Clap 2, so an upgrade will be needed to fix this properly. That upgrade is already prepared in #3064 :tada: