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
1616- Add parentheses if ` Yield ` breaks onto multiple lines.
1717- Ensure all nodes that could have heredocs nested know about their end lines.
1818- 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.
1920
2021### Changed
2122
Original file line number Diff line number Diff line change @@ -4204,20 +4204,7 @@ def format(q)
42044204 q . group do
42054205 q . text ( "def " )
42064206 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?
42214208 end
42224209
42234210 unless bodystmt . empty?
@@ -4519,20 +4506,7 @@ def format(q)
45194506 q . format ( target )
45204507 q . format ( CallOperatorFormatter . new ( operator ) )
45214508 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?
45364510 end
45374511
45384512 unless bodystmt . empty?
@@ -6143,11 +6117,17 @@ def child_nodes
61436117 def format ( q )
61446118 contents = -> do
61456119 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
61476128 q . breakable
6148- q . format ( HashFormatter . for ( self ) )
61496129 end
6150- q . breakable
6130+
61516131 q . text ( "}" )
61526132 end
61536133
@@ -8742,9 +8722,21 @@ def format(q)
87428722 parts << KeywordRestFormatter . new ( keyword_rest ) if keyword_rest
87438723 parts << block if block
87448724
8745- q . nest ( 0 ) do
8725+ contents = -> {
87468726 q . seplist ( parts ) { |part | q . format ( part ) }
87478727 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 )
87488740 end
87498741 end
87508742
You can’t perform that action at this time.
0 commit comments