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:
commit
5dba81bbbf
4 changed files with 8 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
1
tests/config/issue-2641.toml
Normal file
1
tests/config/issue-2641.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
newline_style = "Windows"
|
||||
3
tests/source/issue-2641.rs
Normal file
3
tests/source/issue-2641.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
macro_rules! a {
|
||||
() => {{}}
|
||||
}
|
||||
3
tests/target/issue-2641.rs
Normal file
3
tests/target/issue-2641.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
macro_rules! a {
|
||||
() => {{}};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue