Reduce the max width by the width of indent

This commit is contained in:
Seiichi Uchida 2018-08-16 07:46:59 +09:00
parent 71dc033fca
commit 9a5a86164f

View File

@ -1277,12 +1277,10 @@ fn rewrite(
let body_indent = if has_block_body { let body_indent = if has_block_body {
shape.indent shape.indent
} else { } else {
// We'll hack the indent below, take this into account when formatting, shape.indent.block_indent(&config)
let body_indent = shape.indent.block_indent(&config);
let new_width = config.max_width() - body_indent.width();
config.set().max_width(new_width);
body_indent
}; };
let new_width = config.max_width() - body_indent.width();
config.set().max_width(new_width);
// First try to format as items, then as statements. // First try to format as items, then as statements.
let new_body = match ::format_snippet(&body_str, &config) { let new_body = match ::format_snippet(&body_str, &config) {