class Rufo::Formatter

def do_align(elements)

def do_align(elements)
  lines = @output.lines
  elements.reject! { |l, c, indent, id, off, ignore| ignore == :ignore }
  # Chunk comments that are in consecutive lines
  chunks = chunk_while(elements) do |(l1, c1, i1, id1), (l2, c2, i2, id2)|
    l1 + 1 == l2 && i1 == i2 && id1 == id2
  end
  chunks.each do |comments|
    next if comments.size == 1
    max_column = comments.map { |l, c| c }.max
    comments.each do |(line, column, _, _, offset)|
      next if column == max_column
      split_index  = column
      split_index -= offset if offset
      target_line = lines[line]
      before = target_line[0...split_index]
      after  = target_line[split_index..-1]
      filler      = " " * (max_column - column)
      lines[line] = "#{before}#{filler}#{after}"
    end
  end
  @output = lines.join
end