class MockVimBuffer
  def initialize(buffer_text)
    @buffer_lines = buffer_text.split("\n")
  end

  def delete(one_indexed_n)
    @buffer_lines.delete_at(one_indexed_n - 1)
  end

  def append(index, string)
    @buffer_lines.insert(index, string)
  end

  def count
    @buffer_lines.length
  end

  def [](one_indexed_n)
    @buffer_lines[one_indexed_n - 1]
  end

  def to_s
    @buffer_lines.join("\n")
  end
end

class MockVimBuffer
  def initialize(buffer_text)
    @buffer_lines = buffer_text.split("\n")
  end

  def delete(one_indexed_n)
    @buffer_lines.delete_at(one_indexed_n - 1)
  end

  def append(index, string)
    # We replace newlines with "^@" because that's what a real vim buffer will
    # output if you append such a string.
    @buffer_lines.insert(index, string.gsub("\n", '^@'))
  end

  def count
    @buffer_lines.length
  end

  def [](one_indexed_n)
    @buffer_lines[one_indexed_n - 1]
  end

  def to_s
    @buffer_lines.join("\n")
  end
end

Make mock buffer behave more like a real buffer
Make mock buffer behave more like a real buffer

If you try to append a string with \n newline characters in it, a real
vim buffer will output "^@" in place of the newline characters. The
mock buffer that we've been using didn't do that which led to a bug
fixed in https://github.com/trotzig/import-js/commit/5f91595aa4. Making
the mock behave more like a real buffer will prevent us from making this
mistake again.

Fixes #13
