Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b318e5a

Browse files
committed
Increase the max width by tab width when using format_code_block
since the macro body will be surrounded by fn main block.
1 parent 9a5a861 commit b318e5a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/macros.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,10 +1285,14 @@ impl MacroBranch {
12851285
// First try to format as items, then as statements.
12861286
let new_body = match ::format_snippet(&body_str, &config) {
12871287
Some(new_body) => new_body,
1288-
None => match ::format_code_block(&body_str, &config) {
1289-
Some(new_body) => new_body,
1290-
None => return None,
1291-
},
1288+
None => {
1289+
let new_width = new_width + config.tab_spaces();
1290+
config.set().max_width(new_width);
1291+
match ::format_code_block(&body_str, &config) {
1292+
Some(new_body) => new_body,
1293+
None => return None,
1294+
}
1295+
}
12921296
};
12931297
let new_body = wrap_str(new_body, config.max_width(), shape)?;
12941298

0 commit comments

Comments
 (0)