diff options
| author | Markus Westerlind <marwes91@gmail.com> | 2018-05-08 20:31:33 +0200 |
|---|---|---|
| committer | Markus Westerlind <marwes91@gmail.com> | 2018-05-08 20:34:44 +0200 |
| commit | 4c9ef93df7e7984bbe1077aa3c24ae538fa0a42c (patch) | |
| tree | f63c1f584714bc0b5246bd78af89c7f459632d0c /src | |
| parent | f46f4b5f665675826bf9756c0e0896d5a5ef92d1 (diff) | |
fix: Don't insert an extra brace in macros with native newlines
Due to `format_snippet` formatting the input with \r\n the subtraction would wouldn't give a length that removed the } Fixes #2641
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 e8bd331f968..80b0764e513 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -645,7 +645,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 { |
