File tree Expand file tree Collapse file tree 2 files changed +25
-32
lines changed Expand file tree Collapse file tree 2 files changed +25
-32
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
16
16
- Add parentheses if ` Yield ` breaks onto multiple lines.
17
17
- Ensure all nodes that could have heredocs nested know about their end lines.
18
18
- Ensure comments on assignment after the ` = ` before the value keep their place.
19
+ - Trailing comments on parameters with no parentheses now do not force a break.
19
20
20
21
### Changed
21
22
Original file line number Diff line number Diff line change @@ -4204,20 +4204,7 @@ def format(q)
4204
4204
q . group do
4205
4205
q . text ( "def " )
4206
4206
q . format ( name )
4207
-
4208
- if !params . is_a? ( Params )
4209
- q . format ( params )
4210
- elsif !params . empty?
4211
- q . group do
4212
- q . text ( "(" )
4213
- q . indent do
4214
- q . breakable ( "" )
4215
- q . format ( params )
4216
- end
4217
- q . breakable ( "" )
4218
- q . text ( ")" )
4219
- end
4220
- end
4207
+ q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
4221
4208
end
4222
4209
4223
4210
unless bodystmt . empty?
@@ -4519,20 +4506,7 @@ def format(q)
4519
4506
q . format ( target )
4520
4507
q . format ( CallOperatorFormatter . new ( operator ) )
4521
4508
q . format ( name )
4522
-
4523
- if !params . is_a? ( Params )
4524
- q . format ( params )
4525
- elsif !params . empty?
4526
- q . group do
4527
- q . text ( "(" )
4528
- q . indent do
4529
- q . breakable ( "" )
4530
- q . format ( params )
4531
- end
4532
- q . breakable ( "" )
4533
- q . text ( ")" )
4534
- end
4535
- end
4509
+ q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
4536
4510
end
4537
4511
4538
4512
unless bodystmt . empty?
@@ -6143,11 +6117,17 @@ def child_nodes
6143
6117
def format ( q )
6144
6118
contents = -> do
6145
6119
q . format ( lbrace )
6146
- q . indent do
6120
+
6121
+ if assocs . empty?
6122
+ q . breakable ( "" )
6123
+ else
6124
+ q . indent do
6125
+ q . breakable
6126
+ q . format ( HashFormatter . for ( self ) )
6127
+ end
6147
6128
q . breakable
6148
- q . format ( HashFormatter . for ( self ) )
6149
6129
end
6150
- q . breakable
6130
+
6151
6131
q . text ( "}" )
6152
6132
end
6153
6133
@@ -8742,9 +8722,21 @@ def format(q)
8742
8722
parts << KeywordRestFormatter . new ( keyword_rest ) if keyword_rest
8743
8723
parts << block if block
8744
8724
8745
- q . nest ( 0 ) do
8725
+ contents = -> {
8746
8726
q . seplist ( parts ) { |part | q . format ( part ) }
8747
8727
q . format ( rest ) if rest && rest . is_a? ( ExcessedComma )
8728
+ }
8729
+
8730
+ if [ Def , Defs ] . include? ( q . parent . class )
8731
+ q . group ( 0 , "(" , ")" ) do
8732
+ q . indent do
8733
+ q . breakable ( "" )
8734
+ contents . call
8735
+ end
8736
+ q . breakable ( "" )
8737
+ end
8738
+ else
8739
+ q . nest ( 0 , &contents )
8748
8740
end
8749
8741
end
8750
8742
You can’t perform that action at this time.
0 commit comments