File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -4536,6 +4536,7 @@ def deconstruct_keys(keys)
45364536 def format ( q )
45374537 parts = keywords . map { |( key , value ) | KeywordFormatter . new ( key , value ) }
45384538 parts << KeywordRestFormatter . new ( keyword_rest ) if keyword_rest
4539+
45394540 contents = -> do
45404541 q . seplist ( parts ) { |part | q . format ( part , stackable : false ) }
45414542 end
@@ -4546,8 +4547,9 @@ def format(q)
45464547 return
45474548 end
45484549
4549- parent = q . parent
4550- if PATTERNS . include? ( parent . class )
4550+ if parts . empty?
4551+ q . text ( "{}" )
4552+ elsif PATTERNS . include? ( q . parent . class )
45514553 q . text ( "{ " )
45524554 contents . call
45534555 q . text ( " }" )
Original file line number Diff line number Diff line change @@ -1501,13 +1501,19 @@ def on_heredoc_end(value)
15011501 # (nil | VarField) keyword_rest
15021502 # ) -> HshPtn
15031503 def on_hshptn ( constant , keywords , keyword_rest )
1504- parts = [ constant , keywords , keyword_rest ] . flatten ( 2 ) . compact
1504+ parts = [ constant , *keywords &.flatten ( 1 ) , keyword_rest ] . compact
1505+ location =
1506+ if parts . empty?
1507+ find_token ( LBrace ) . location . to ( find_token ( RBrace ) . location )
1508+ else
1509+ parts [ 0 ] . location . to ( parts [ -1 ] . location )
1510+ end
15051511
15061512 HshPtn . new (
15071513 constant : constant ,
1508- keywords : keywords ,
1514+ keywords : keywords || [ ] ,
15091515 keyword_rest : keyword_rest ,
1510- location : parts [ 0 ] . location . to ( parts [ - 1 ] . location )
1516+ location : location
15111517 )
15121518 end
15131519
Original file line number Diff line number Diff line change 4444case foo
4545in Foo[**bar]
4646end
47+ %
48+ case foo
49+ in {}
50+ end
You can’t perform that action at this time.
0 commit comments