class Rufo::Formatter
def visit_hash(node)
def visit_hash(node) # [:hash, elements] _, elements = node token_column = current_token_column closing_brace_token, _ = find_closing_brace_token need_space = need_space_for_hash?(node, node[1], closing_brace_token) check :on_lbrace write "{" brace_position = @output.length - 1 write " " if need_space next_token if elements # [:assoclist_from_args, elements] push_hash(node) do visit_literal_elements(elements[1], inside_hash: true, token_column: token_column) end char_after_brace = @output[brace_position + 1] # Check that need_space is set correctly. if !need_space && !["\n", " "].include?(char_after_brace) need_space = true # Add a space in the missing position. @output.insert(brace_position + 1, " ") end else skip_space_or_newline end check :on_rbrace write " " if need_space write "}" next_token end