@@ -130,13 +130,26 @@ impl<'a> FmtVisitor<'a> {
130
130
let ret_str = self . rewrite_return ( & fd. output ) ;
131
131
132
132
// Args.
133
- let ( one_line_budget, multi_line_budget, arg_indent) =
134
- self . compute_budgets_for_args ( & mut result, indent, ret_str. len ( ) , newline_brace) ;
133
+ let ( one_line_budget, multi_line_budget, mut arg_indent) =
134
+ self . compute_budgets_for_args ( & result, indent, ret_str. len ( ) , newline_brace) ;
135
135
136
136
debug ! ( "rewrite_fn: one_line_budget: {}, multi_line_budget: {}, arg_indent: {}" ,
137
137
one_line_budget, multi_line_budget, arg_indent) ;
138
138
139
- result. push ( '(' ) ;
139
+ if one_line_budget <= 0 {
140
+ if config ! ( fn_args_paren_newline) {
141
+ result. push ( '\n' ) ;
142
+ result. push_str ( & make_indent ( arg_indent) ) ;
143
+ arg_indent = arg_indent + 1 ;
144
+ result. push ( '(' ) ;
145
+ } else {
146
+ result. push_str ( "(\n " ) ;
147
+ result. push_str ( & make_indent ( arg_indent) ) ;
148
+ }
149
+ } else {
150
+ result. push ( '(' ) ;
151
+ }
152
+
140
153
result. push_str ( & self . rewrite_args ( & fd. inputs ,
141
154
explicit_self,
142
155
one_line_budget,
@@ -330,7 +343,7 @@ impl<'a> FmtVisitor<'a> {
330
343
}
331
344
332
345
fn compute_budgets_for_args ( & self ,
333
- result : & mut String ,
346
+ result : & String ,
334
347
indent : usize ,
335
348
ret_str_len : usize ,
336
349
newline_brace : bool )
@@ -365,8 +378,6 @@ impl<'a> FmtVisitor<'a> {
365
378
366
379
// Didn't work. we must force vertical layout and put args on a newline.
367
380
if let None = budgets {
368
- result. push ( '\n' ) ;
369
- result. push_str ( & make_indent ( indent + 4 ) ) ;
370
381
// 6 = new indent + `()`
371
382
let used_space = indent + 6 ;
372
383
let max_space = config ! ( ideal_width) + config ! ( leeway) ;
@@ -375,7 +386,7 @@ impl<'a> FmtVisitor<'a> {
375
386
// TODO take evasive action, perhaps kill the indent or something.
376
387
} else {
377
388
// 5 = new indent + `(`
378
- budgets = Some ( ( 0 , max_space - used_space, indent + 5 ) ) ;
389
+ budgets = Some ( ( 0 , max_space - used_space, indent + 4 ) ) ;
379
390
}
380
391
}
381
392
0 commit comments