This commit is contained in:
DarkDrek 2016-01-27 02:18:05 +01:00
parent 4344c51c80
commit feb09a42f5
3 changed files with 10 additions and 4 deletions

View File

@ -147,11 +147,11 @@ impl<'a> FmtVisitor<'a> {
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() {
} else if line_start <= snippet.len() {
// 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");
match snippet[line_start..].chars().next() {
Some('\n') | Some('\r') => (),
_ => self.buffer.push_str("\n"),
}
}

View File

@ -45,3 +45,5 @@ fn chains() {
/*
* random comment */
fn main() {/* Test */}

View File

@ -46,3 +46,7 @@ fn chains() {
}
// random comment
fn main() {
// Test
}