File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
37
37
- Allow for the possibility that ` CommandCall ` nodes might not have arguments.
38
38
- Explicitly handle ` ?" ` so that it formats properly.
39
39
- Check that a block is within the predicate in a more relaxed way.
40
+ - Ensure the ` Return ` breaks with brackets and not parentheses.
40
41
41
42
### Removed
42
43
Original file line number Diff line number Diff line change @@ -2930,20 +2930,35 @@ def format(q)
2930
2930
q . text ( keyword )
2931
2931
2932
2932
if arguments . parts . any?
2933
- if arguments . parts . length == 1 && arguments . parts . first . is_a? ( Paren )
2934
- q . format ( arguments )
2935
- else
2936
- q . if_break { q . text ( "(" ) }
2937
- q . indent do
2938
- q . breakable ( " " )
2933
+ if arguments . parts . length == 1
2934
+ part = arguments . parts . first
2935
+
2936
+ if part . is_a? ( Paren )
2937
+ q . format ( arguments )
2938
+ elsif part . is_a? ( ArrayLiteral )
2939
+ q . text ( " " )
2939
2940
q . format ( arguments )
2941
+ else
2942
+ format_arguments ( q , "(" , ")" )
2940
2943
end
2941
- q . breakable ( "" )
2942
- q . if_break { q . text ( ")" ) }
2944
+ else
2945
+ format_arguments ( q , " [" , "]" )
2943
2946
end
2944
2947
end
2945
2948
end
2946
2949
end
2950
+
2951
+ private
2952
+
2953
+ def format_arguments ( q , opening , closing )
2954
+ q . if_break { q . text ( opening ) }
2955
+ q . indent do
2956
+ q . breakable ( " " )
2957
+ q . format ( node . arguments )
2958
+ end
2959
+ q . breakable ( "" )
2960
+ q . if_break { q . text ( closing ) }
2961
+ end
2947
2962
end
2948
2963
2949
2964
# Break represents using the +break+ keyword.
You can’t perform that action at this time.
0 commit comments