class Rufo::Formatter

def indent_body(exps, force_multiline: false)

def indent_body(exps, force_multiline: false)
  first_space = skip_space
  has_semicolon = semicolon?
  if has_semicolon
    next_token
    skip_semicolons
    first_space = nil
  end
  # If an end follows there's nothing to do
  if keyword?("end")
    if has_semicolon
      write "; "
    else
      write_space_using_setting(first_space, :one)
    end
    return
  end
  # A then keyword can appear after a newline after an `if`, `unless`, etc.
  # Since that's a super weird formatting for if, probably way too obsolete
  # by now, we just remove it.
  has_then = keyword?("then")
  if has_then
    next_token
    second_space = skip_space
  end
  has_do = keyword?("do")
  if has_do
    next_token
    second_space = skip_space
  end
  # If no newline or comment follows, we format it inline.
  if !force_multiline && !(newline? || comment?)
    if has_then
      write " then "
    elsif has_do
      write_space_using_setting(first_space, :one, at_least_one: true)
      write "do"
      write_space_using_setting(second_space, :one, at_least_one: true)
    elsif has_semicolon
      write "; "
    else
      write_space_using_setting(first_space, :one, at_least_one: true)
    end
    visit_exps exps, with_indent: false, with_lines: false
    consume_space
    return
  end
  indent do
    consume_end_of_line(want_multiline: false)
  end
  if keyword?("then")
    next_token
    skip_space_or_newline
  end
  # If the body is [[:void_stmt]] it's an empty body
  # so there's nothing to write
  if exps.size == 1 && exps[0][0] == :void_stmt
    skip_space_or_newline
  else
    indent do
      visit_exps exps, with_indent: true
    end
    write_line unless @last_was_newline
  end
end