Closed jsejcksn closed 2 months ago
Thanks for pointing this out! I will just remove these newlines and let the terminal handle line wrapping.
Thanks for pointing this out! I will just remove these newlines and let the terminal handle line wrapping.
@mo8it That would fix the described issue, but… hanging indentation improves readability — and list items are harder to scan and differentiate from other block content without it. I think that the crate unicode-segmentation
can help with generating lines to fit terminals. It might require a different (more complex) kind of structure for the existing messages, but I think readability is important in terminal UX.
Edit: I haven't looked at all of the sources for these pre-formatted messages, but perhaps they can be parsed as markdown in order to be formatted as appropriate for different destinations — e.g. formatting long list items with hanging indentation in a terminal. This might also open up the possibility to generate a content index on the website in the future if desired…
After merging your PR, I think the best way to solve this is to manually break after the length of 80. But I don't want to enforce it, especially not for third-party exercises. Because the compiler messages shown by Rustlings don't limit their output at 80 and require wrapping anyway. So I will leave it to the user if they want to wrap manually or let the terminal wrap.
@mo8it Understood. If you change your mind about this in the future, feel free to let me know: I might like to work on the kind of feature that I described.
It would be helpful to format messages with a fixed line length limit instead of printing pre-formatted strings as-is — in order to avoid undesirable line-breaks/malformed indentation for users who are not using wider terminals.
Toward a solution: rustlings could read the number of columns reported by the terminal and then transform message texts to break and re-indent as appropriate… falling back to a standardized lowest-common-denominator (I think the most common standard is
80
^1). Without such a feature (or until it can be implemented), the existing messages could simply be re-formatted to break at that LCD length.Here's an example to illustrate the problem I described: when using a terminal with a width of 80 columns, I see the welcome message printed this way: