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 @@ -3060,7 +3060,10 @@ def format(q)
3060
3060
q . group do
3061
3061
q . text ( "def " )
3062
3062
q . format ( name )
3063
- q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
3063
+
3064
+ if !params . is_a? ( Params ) || !params . empty? || params . comments . any?
3065
+ q . format ( params )
3066
+ end
3064
3067
end
3065
3068
3066
3069
unless bodystmt . empty?
@@ -3280,7 +3283,10 @@ def format(q)
3280
3283
q . format ( target )
3281
3284
q . format ( CallOperatorFormatter . new ( operator ) , stackable : false )
3282
3285
q . format ( name )
3283
- q . format ( params ) if !params . is_a? ( Params ) || !params . empty?
3286
+
3287
+ if !params . is_a? ( Params ) || !params . empty? || params . comments . any?
3288
+ q . format ( params )
3289
+ end
3284
3290
end
3285
3291
3286
3292
unless bodystmt . empty?
@@ -6317,16 +6323,16 @@ def format(q)
6317
6323
q . format ( rest ) if rest && rest . is_a? ( ExcessedComma )
6318
6324
end
6319
6325
6320
- if [ Def , Defs , DefEndless ] . include? ( q . parent . class )
6326
+ if ![ Def , Defs , DefEndless ] . include? ( q . parent . class ) || parts . empty?
6327
+ q . nest ( 0 , &contents )
6328
+ else
6321
6329
q . group ( 0 , "(" , ")" ) do
6322
6330
q . indent do
6323
6331
q . breakable ( "" )
6324
6332
contents . call
6325
6333
end
6326
6334
q . breakable ( "" )
6327
6335
end
6328
- else
6329
- q . nest ( 0 , &contents )
6330
6336
end
6331
6337
end
6332
6338
end
@@ -8394,8 +8400,6 @@ def format(q)
8394
8400
q . text ( ")" )
8395
8401
elsif ternary
8396
8402
q . if_break { } . if_flat { q . text ( ")" ) }
8397
- else
8398
- q . text ( " " )
8399
8403
end
8400
8404
end
8401
8405
end
You can’t perform that action at this time.
0 commit comments