Skip to content

Conversation

matthewhughes934
Copy link

The comment style detection (i.e. comment_style) checks the start of a line to determine the style, so it will misidentify lines starting with spaces, e.g. //# some content would be identified as CommentStyle::DoubleSlash and not CommentStyle::Custom("//# ") resulting in it determining there to be a comment of "", which it then indents and appends a \n before writing back the original comment.

Fix this by trimming the line before trying to identify its style.

Fixes: #6612

The comment style detection (i.e. `comment_style`) checks the start of a
line to determine the style, so it will misidentify lines starting with
spaces, e.g. `  //# some content` would be identified as
`CommentStyle::DoubleSlash` and not `CommentStyle::Custom("//# ")`
resulting in it determining there to be a comment of `""`, which it then
indents and appends a `\n` before writing back the original comment.

Fix this by trimming the line before trying to identify its style.

Fixes: rust-lang#6612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

format_code_in_doc_comments adds empty line between trailing comment and hidden code
2 participants