Skip to content

Commit

Permalink
Merge pull request #313 from ruby-formatter/fix-312
Browse files Browse the repository at this point in the history
Fix #312
  • Loading branch information
kzkn authored Nov 8, 2023
2 parents 387b741 + a40c78f commit 0fae9cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/rufo/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,15 @@ def visit_hash_pattern(node)

visit_literal_elements elements, inside_hash: true, token_column: token_column, keep_final_newline: expected_right_token.nil? do |element|
key, value = element
visit key

if current_token_kind == :on_tstring_beg
consume_token :on_tstring_beg
visit key
consume_token :on_label_end
else
visit key
end

if value
consume_space
visit value
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec
Original file line number Diff line number Diff line change
Expand Up @@ -784,3 +784,15 @@ case x
in 1..3
"a"
end

#~# ORIGINAL issue_312
case x
in {"a": 1}
1
end

#~# EXPECTED
case x
in { "a": 1 }
1
end

0 comments on commit 0fae9cc

Please sign in to comment.