File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -352,13 +352,15 @@ where
352
352
. and_then ( |s| s. sub_width ( pp. suffix . len ( ) ) )
353
353
. and_then ( |rhs_shape| rhs. rewrite ( context, rhs_shape) ) ;
354
354
if let Some ( ref rhs_result) = rhs_orig_result {
355
- // If the rhs looks like block expression, we allow it to stay on the same line
356
- // with the lhs even if it is multi-lined.
357
- let allow_same_line = rhs_result
358
- . lines ( )
359
- . next ( )
360
- . map ( |first_line| first_line. ends_with ( '{' ) )
361
- . unwrap_or ( false ) ;
355
+ // If the length of the lhs is equal to or shorter than the tab width or
356
+ // the rhs looks like block expression, we put the rhs on the same
357
+ // line with the lhs even if the rhs is multi-lined.
358
+ let allow_same_line = lhs_result. len ( ) <= context. config . tab_spaces ( )
359
+ || rhs_result
360
+ . lines ( )
361
+ . next ( )
362
+ . map ( |first_line| first_line. ends_with ( '{' ) )
363
+ . unwrap_or ( false ) ;
362
364
if !rhs_result. contains ( '\n' ) || allow_same_line {
363
365
let one_line_width = last_line_width ( & lhs_result) + pp. infix . len ( )
364
366
+ first_line_width ( rhs_result) + pp. suffix . len ( ) ;
You can’t perform that action at this time.
0 commit comments