mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-12 20:16:49 +00:00
Merge pull request #634 from Marwes/block_comment_crlf
Avoid adding an extra newline after block comments
This commit is contained in:
commit
7809e3bb18
@ -145,11 +145,12 @@ impl<'a> FmtVisitor<'a> {
|
||||
line_start = offset + subslice.len();
|
||||
|
||||
if let Some('/') = subslice.chars().skip(1).next() {
|
||||
// Add a newline after line comments
|
||||
self.buffer.push_str("\n");
|
||||
} else if line_start < snippet.len() {
|
||||
let x = (&snippet[line_start..]).chars().next().unwrap() != '\n';
|
||||
|
||||
if x {
|
||||
// For other comments add a newline if there isn't one at the end already
|
||||
let c = snippet[line_start..].chars().next().unwrap();
|
||||
if c != '\n' && c != '\r' {
|
||||
self.buffer.push_str("\n");
|
||||
}
|
||||
}
|
||||
|
3
tests/source/comment_crlf_newline.rs
Normal file
3
tests/source/comment_crlf_newline.rs
Normal file
@ -0,0 +1,3 @@
|
||||
/* Block comments followed by CRLF newlines should not an extra newline at the end */
|
||||
|
||||
/* Something else */
|
3
tests/target/comment_crlf_newline.rs
Normal file
3
tests/target/comment_crlf_newline.rs
Normal file
@ -0,0 +1,3 @@
|
||||
// Block comments followed by CRLF newlines should not an extra newline at the end
|
||||
|
||||
// Something else
|
Loading…
Reference in New Issue
Block a user