diff options
| author | Nick Cameron <nrc@ncameron.org> | 2018-05-09 13:18:27 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-09 13:18:27 +1200 |
| commit | 5dba81bbbf0f352335b240fbf1cd64e5f3ca447f (patch) | |
| tree | 9d70f8501a1aa7560c7ec0fc7dc301e84cf6a670 /src | |
| parent | 659d0c97412f2b010003df445f4c9cd84aa4bc75 (diff) | |
| parent | 4c9ef93df7e7984bbe1077aa3c24ae538fa0a42c (diff) | |
Merge pull request #2687 from Marwes/issue_2641
fix: Don't insert an extra brace in macros with native newlines
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs index 73c3fdd48c2..48c9295c4f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { |
