Merge pull request #785 from DarkDrek/fix-#784
Fix for #784 edge case in comment handling
This commit is contained in:
commit
fb17a44584
3 changed files with 10 additions and 4 deletions
|
@ -147,11 +147,11 @@ impl<'a> FmtVisitor<'a> {
|
||||||
if let Some('/') = subslice.chars().skip(1).next() {
|
if let Some('/') = subslice.chars().skip(1).next() {
|
||||||
// Add a newline after line comments
|
// Add a newline after line comments
|
||||||
self.buffer.push_str("\n");
|
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
|
// For other comments add a newline if there isn't one at the end already
|
||||||
let c = snippet[line_start..].chars().next().unwrap();
|
match snippet[line_start..].chars().next() {
|
||||||
if c != '\n' && c != '\r' {
|
Some('\n') | Some('\r') => (),
|
||||||
self.buffer.push_str("\n");
|
_ => self.buffer.push_str("\n"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,3 +45,5 @@ fn chains() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* random comment */
|
* random comment */
|
||||||
|
|
||||||
|
fn main() {/* Test */}
|
||||||
|
|
|
@ -46,3 +46,7 @@ fn chains() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// random comment
|
// random comment
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Test
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue