Skip to content

lists: Detect block comment by starting from the end. #3048

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

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Sep 22, 2018

The issue with the current code is that comments are collapsed, so comments like
the one from the test end up in a string like:

"// this is a single line comment\n/* block = */"

I chose to fix it by detecting whether we're in a block comment starting from
the end instead, and tested a single-line comment ended in */ just for sanity,
ensuring line breaks are not removed in that case, which would break the
formatting.

The right fix eventually is probably to lex the comments properly, but this does
the work for now, I guess :)

Fixes #3025

The issue with the current code is that comments are collapsed, so comments like
the one from the test end up in a string like:

```
"// this is a single line comment\n/* block = */"
```

I chose to fix it by detecting whether we're in a block comment starting from
the end instead, and tested a single-line comment ended in `*/` just for sanity,
ensuring line breaks are not removed in that case, which would break the
formatting.

The right fix eventually is probably to lex the comments properly, but this does
the work for now, I guess :)

Fixes rust-lang#3025
@emilio
Copy link
Contributor Author

emilio commented Sep 22, 2018

r? @topecongiro or @nrc

@nrc nrc merged commit ac6871f into rust-lang:master Sep 24, 2018
@nrc
Copy link
Member

nrc commented Sep 24, 2018

Thank you!

@emilio emilio deleted the merged-comments branch September 24, 2018 09:20
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 this pull request may close these issues.

Argument name comment gets boken if there's another comment before.
2 participants