Merge pull request #2687 from Marwes/issue_2641

fix: Don't insert an extra brace in macros with native newlines
This commit is contained in:
Nick Cameron 2018-05-09 13:18:27 +12:00 committed by GitHub
commit 5dba81bbbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View file

@ -646,7 +646,7 @@ pub fn format_code_block(code_snippet: &str, config: &Config) -> Option<String>
// then unindent the whole code block.
let formatted = format_snippet(&snippet, config)?;
// 2 = "}\n"
let block_len = formatted.len().checked_sub(2).unwrap_or(0);
let block_len = formatted.rfind('}').unwrap_or(formatted.len());
let mut is_indented = true;
for (kind, ref line) in LineClasses::new(&formatted[FN_MAIN_PREFIX.len()..block_len]) {
if !is_first {

View file

@ -0,0 +1 @@
newline_style = "Windows"

View file

@ -0,0 +1,3 @@
macro_rules! a {
() => {{}}
}

View file

@ -0,0 +1,3 @@
macro_rules! a {
() => {{}};
}