Check the length of the first line of the last method in the chain
This commit is contained in:
parent
1c1ad525f6
commit
8dc53d3750
1 changed files with 13 additions and 6 deletions
|
@ -195,12 +195,19 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
||||||
if fits_single_line {
|
if fits_single_line {
|
||||||
fits_single_line = match expr.node {
|
fits_single_line = match expr.node {
|
||||||
ref e @ ast::ExprKind::MethodCall(..) => {
|
ref e @ ast::ExprKind::MethodCall(..) => {
|
||||||
rewrite_method_call_with_overflow(e,
|
if rewrite_method_call_with_overflow(e,
|
||||||
&mut last[0],
|
&mut last[0],
|
||||||
almost_total,
|
almost_total,
|
||||||
total_span,
|
total_span,
|
||||||
context,
|
context,
|
||||||
shape)
|
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'),
|
_ => !last[0].contains('\n'),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue