Skip to content

Commit be19bab

Browse files
committed
Take into account the rhs overhead when rewriting the last element of chain
1 parent 4436508 commit be19bab

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/chains.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,11 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
166166
let all_in_one_line = !parent_rewrite_contains_newline
167167
&& rewrites.iter().all(|s| !s.contains('\n'))
168168
&& almost_total < one_line_budget;
169-
let last_shape = {
170-
let last_shape = if rewrites.len() == 0 {
171-
first_child_shape
172-
} else {
173-
other_child_shape
174-
};
175-
match context.config.indent_style() {
176-
IndentStyle::Visual => last_shape.sub_width(shape.rhs_overhead(context.config))?,
177-
IndentStyle::Block => last_shape,
178-
}
179-
};
180-
let last_shape = last_shape.sub_width(suffix_try_num)?;
169+
let last_shape = if rewrites.len() == 0 {
170+
first_child_shape
171+
} else {
172+
other_child_shape
173+
}.sub_width(shape.rhs_overhead(context.config) + suffix_try_num)?;
181174

182175
// Rewrite the last child. The last child of a chain requires special treatment. We need to
183176
// know whether 'overflowing' the last child make a better formatting:

0 commit comments

Comments
 (0)