Skip to content

Commit

Permalink
Merge pull request #3533 from rchaser53/issue-3532
Browse files Browse the repository at this point in the history
fix Comma in comment causes no formatting
  • Loading branch information
scampi committed May 1, 2019
2 parents d3ec460 + 2c58b20 commit 8c94e2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lists.rs
Expand Up @@ -612,7 +612,7 @@ pub fn extract_post_comment(
post_snippet[1..].trim_matches(white_space)
} else if post_snippet.starts_with(separator) {
post_snippet[separator.len()..].trim_matches(white_space)
} else if post_snippet.ends_with(',') {
} else if post_snippet.ends_with(',') && !post_snippet.trim().starts_with("//") {
post_snippet[..(post_snippet.len() - 1)].trim_matches(white_space)
} else {
post_snippet
Expand Down
7 changes: 7 additions & 0 deletions tests/source/issue-3532.rs
@@ -0,0 +1,7 @@
fn foo(a: T) {
match a {
1 => {}
0 => {}
// _ => panic!("doesn't format!"),
}
}
6 changes: 6 additions & 0 deletions tests/target/issue-3532.rs
@@ -0,0 +1,6 @@
fn foo(a: T) {
match a {
1 => {}
0 => {} // _ => panic!("doesn't format!"),
}
}

0 comments on commit 8c94e2b

Please sign in to comment.