Skip to content

Fix misidentification of indented comments #6617

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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