Skip to content

VSCode doesn't show new line on comments like Cargo doc does #1997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jasonwilliams opened this issue Oct 11, 2019 · 9 comments · Fixed by #2101
Closed

VSCode doesn't show new line on comments like Cargo doc does #1997

jasonwilliams opened this issue Oct 11, 2019 · 9 comments · Fixed by #2101

Comments

@jasonwilliams
Copy link
Member

When i write comments i would like to create a new line.
I've noticed that adding 3 spaces (similar to markdown) on the end creates a new line in the documentation.

For example this:
https://github.com/jasonwilliams/boa/blob/master/src/lib/realm.rs#L21-L22

generates this:
image

But in VSCode its all on 1 line:
image

Can this plugin change that?
Or have i posted this issue in the wrong place.

@kjeremy
Copy link
Contributor

kjeremy commented Oct 11, 2019

What does RLS do with that comment?

@jasonwilliams
Copy link
Member Author

I think with RLS it worked, but can’t confirm

@marcogroppo
Copy link
Contributor

rust-analyzer trims all whitespace at the end of the line inside doc comments. I'll file a PR.

@marcogroppo
Copy link
Contributor

Sorry @kjeremy I've just seen now that this is related to #1630. The obvious patch (not trimming if there are 3 spaces at the end of the line) would break test_doc_comment_multi_line_block_strips_suffix https://github.com/rust-analyzer/rust-analyzer/blob/4ba2c5b2de0d1815007d109b3897ccaf6dda0ab5/crates/ra_syntax/src/ast.rs#L180
but this is not what we want, I suppose 🤔

@jasonwilliams
Copy link
Member Author

@marcogroppo could you elaborate what would break and why?

@matklad
Copy link
Member

matklad commented Oct 14, 2019

I must say that I am sad that we, as an industry, somehow arrived at the markup format where the trailing whitespace is significant :)

But yeah, we should strip only leading whitespace from the docs, not the trailing

@kjeremy
Copy link
Contributor

kjeremy commented Oct 14, 2019

Huh... I had no idea that adding spaces to the end would do that in markdown. A quick skim of rls code leads me to believe that they do not trim the end of the line but I still think we need to remove the */ in a multiline comment. PR welcome!

@jasonwilliams
Copy link
Member Author

jasonwilliams commented Oct 14, 2019

@kjeremy how do you mean you need to remove the */ in a multiline comment?
I wouldnt know where to start in a PR for this, are there any places in the code you can point to

@kjeremy
Copy link
Contributor

kjeremy commented Oct 14, 2019

@jasonwilliams

Yes you would remove the */ in multiline comments and make the changes above where we do not strip trailing whitespace. See #1630 for how I originally implemented the removal of the suffix. That's also (doc_comment_text) the function you will need to modify.

bors bot added a commit that referenced this issue Oct 27, 2019
2101: Preserve whitespace at the end of doc comments r=matklad a=kjeremy

Whitespace can have special meaning in markdown. For instance ending a line with three spaces will render a new line.

Note that this behavior diverges from RLS.

Fixes #1997

Co-authored-by: Jeremy Kolb <[email protected]>
@bors bors bot closed this as completed in 1438f38 Oct 27, 2019
@bors bors bot closed this as completed in #2101 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants