Indentation of secont and following lines in multiline comment#4658
Conversation
calebcartwright
left a comment
There was a problem hiding this comment.
Thanks for this! Couple minor things but this looks to be in good order and ready for merging after those are addressed 👍
| ( | ||
| blank, | ||
| trim_end_unless_two_whitespaces(left_trimmed, is_doc_comment), | ||
| ) | ||
| }) | ||
| .map(|(b, l)| format!("{}{}", b, l)) |
There was a problem hiding this comment.
Good catch! I don't see a need for another map call though, let's just return the allocated string in the closure in the previous block like was done before
| ( | |
| blank, | |
| trim_end_unless_two_whitespaces(left_trimmed, is_doc_comment), | |
| ) | |
| }) | |
| .map(|(b, l)| format!("{}{}", b, l)) | |
| format!( | |
| "{}{}", | |
| blank, | |
| trim_end_unless_two_whitespaces(left_trimmed, is_doc_comment), | |
| ) | |
| }) |
| @@ -0,0 +1,46 @@ | |||
| // Ensure multiline comments are indented properly, | |||
| // incluyding when second line is prefixed by tab or at the beginning of the line | |||
There was a problem hiding this comment.
typo fix 😄 also, can you add a copy of this test case but with the hard_tabs set to true? I wouldn't expect any issues, but good to have for regression regardless
| // incluyding when second line is prefixed by tab or at the beginning of the line | |
| // including when second line is prefixed by tab or at the beginning of the line |
There was a problem hiding this comment.
Fixed and added ...-hard-tabs.rs test file.
|
Also, make sure you rebase on |
58149d7 to
0fae9bc
Compare
Done, but I probably didn't do it right, as all/some of the latest master changes are also shown as changes here. What I did is to merge the UPDATE: hopefully fixed the issue by resting the last commit, merging again with master and redoing the changes. Hopefully it is o.k. now. |
0fae9bc to
0145848
Compare
Thanks! The diff looks okay now. For future reference, I would encourage adding this repo as another upstream in your local copy of your fork https://docs.github.com/en/github/using-git/adding-a-remote git remote add upstream https://github.com/rust-lang/rustfmt.gitThat way you can continue working with your fork via the same remote (typically git fetch upstreamand then you can rebase whatever local branch you are working on against the target upstream branch: git checkout master
git rebase upstream/master
# or
git checkout comment_multiline_indentation
git rebase upstream/master |
|
I am willing to back-port this PR, but it is not labeled as "1x-backport:pending ". Is it ok to back-port it, or only if/when it will be labeled as "1x-backport:pending "? A more general question - there are some other PRs I submitted for R2 that are labeled as "1x-backport:pending", but not as "help-wanted". Is it o.k. that I will back-port these PRs? |
…t line indentation
Fix an issue in
light_rewrite_comment()when formatting 2nd (and following) lines that start with*in a multiline comment. Currently, the function prefix it with the byte preceding the*, so it will be aligned with the comment opening/*, assuming this character is a space.The main problem is that if the byte preceding the
*in the original code is a hard-tab, indentation is to the next tab place and not just by one space. Another issue is when the*is the first char in the line. In this case, nothing is added before the*to align it with the/*.This fix makes sure that the
*is prefixed by a space character.