diff --git a/lib/rufo/formatter.rb b/lib/rufo/formatter.rb index c07ccc42..d564a61c 100644 --- a/lib/rufo/formatter.rb +++ b/lib/rufo/formatter.rb @@ -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 diff --git a/spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec b/spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec index e9855928..f0169bc2 100644 --- a/spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec @@ -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