You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// This is a testing comment to test rustdoc markdown. /// This is the next line.pubfnadd(left:usize,right:usize) -> usize{
left + right
}
In rustdoc, this appears like:
However, in VSCode/Lapce, it appears as:
The contents of what VSCode receives:
"contents": {
"kind": "markdown",
"value": "\n```rust\ntesting1\n```\n\n```rust\npub fn add(left: usize, right: usize) -> usize\n```\n\n---\n\nThis is a testing comment to test rustdoc markdown.\nThis is the next line."
},
So it appears that it strips the whitespace at the end of the lines, and then sends it along. Since the receiver is parsing this as markdown, they do the typical behavior of single newlines not being actual linebreaks.
I believe this didn't used to happen until some months back, but I haven't checked which version I remember it being fine on.
It seems to have happened before in #1997 and then been fixed.
The text was updated successfully, but these errors were encountered:
Trailing whitespace having semantic meaning seems really horrible to me.
rustfmt is clearly aware of trailing spaces having meaning in Markdown, as it will trim a single trailing space from doc comments, but won't trim multiple trailing spaces.
As far as I can tell, either any number of trailing spaces greater than one or a trailing backslash indicates a line break, with no difference in meaning. rustfmt allows either of these forms, and does not normalise the number of trailing spaces.
Trailing whitespace having semantic meaning seems really horrible to me.
As side note: CommonMark (which is used by rustdoc) alternatively supports a trailing \ instead of two spaces to create a hard line break (see specification).
But you should check whether at that location a hard line break is actually needed (and there is no implicit line break, e.g. due to usage of > ... in the next line), otherwise the \ might be shown literally, example.
rust-analyzer version: 0.4.1728-standalone
rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)
Example:
In rustdoc, this appears like:

However, in VSCode/Lapce, it appears as:

The contents of what VSCode receives:
So it appears that it strips the whitespace at the end of the lines, and then sends it along. Since the receiver is parsing this as markdown, they do the typical behavior of single newlines not being actual linebreaks.
I believe this didn't used to happen until some months back, but I haven't checked which version I remember it being fine on.
It seems to have happened before in #1997 and then been fixed.
The text was updated successfully, but these errors were encountered: