Check the length of the first line of the last method in the chain

This commit is contained in:
topecongiro 2017-04-15 16:23:38 +09:00
parent 1c1ad525f6
commit 8dc53d3750

View file

@ -195,12 +195,19 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
if fits_single_line {
fits_single_line = match expr.node {
ref e @ ast::ExprKind::MethodCall(..) => {
rewrite_method_call_with_overflow(e,
&mut last[0],
almost_total,
total_span,
context,
shape)
if rewrite_method_call_with_overflow(e,
&mut last[0],
almost_total,
total_span,
context,
shape) {
// If the first line of the last method does not fit into a single line
// after the others, allow new lines.
let first_line = try_opt!(last[0].lines().nth(0));
almost_total + first_line.len() < context.config.max_width
} else {
false
}
}
_ => !last[0].contains('\n'),
}