File tree 1 file changed +11
-7
lines changed 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -3053,7 +3053,10 @@ def format(q)
3053
3053
q . group do
3054
3054
q . text ( "def " )
3055
3055
q . format ( name )
3056
- q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
3056
+
3057
+ if !params . is_a? ( Params ) || !params . empty? || params . comments . any?
3058
+ q . format ( params )
3059
+ end
3057
3060
end
3058
3061
3059
3062
unless bodystmt . empty?
@@ -3273,7 +3276,10 @@ def format(q)
3273
3276
q . format ( target )
3274
3277
q . format ( CallOperatorFormatter . new ( operator ) , stackable : false )
3275
3278
q . format ( name )
3276
- q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
3279
+
3280
+ if !params . is_a? ( Params ) || !params . empty? || params . comments . any?
3281
+ q . format ( params )
3282
+ end
3277
3283
end
3278
3284
3279
3285
unless bodystmt . empty?
@@ -6310,16 +6316,16 @@ def format(q)
6310
6316
q . format ( rest ) if rest && rest . is_a? ( ExcessedComma )
6311
6317
end
6312
6318
6313
- if [ Def , Defs , DefEndless ] . include? ( q . parent . class )
6319
+ if ![ Def , Defs , DefEndless ] . include? ( q . parent . class ) || parts . empty?
6320
+ q . nest ( 0 , &contents )
6321
+ else
6314
6322
q . group ( 0 , "(" , ")" ) do
6315
6323
q . indent do
6316
6324
q . breakable ( "" )
6317
6325
contents . call
6318
6326
end
6319
6327
q . breakable ( "" )
6320
6328
end
6321
- else
6322
- q . nest ( 0 , &contents )
6323
6329
end
6324
6330
end
6325
6331
end
@@ -8387,8 +8393,6 @@ def format(q)
8387
8393
q . text ( ")" )
8388
8394
elsif ternary
8389
8395
q . if_break { } . if_flat { q . text ( ")" ) }
8390
- else
8391
- q . text ( " " )
8392
8396
end
8393
8397
end
8394
8398
end
You can’t perform that action at this time.
0 commit comments