use an Editor in write_debug

This commit is contained in:
Maxime Coste 2012-03-06 23:12:48 +00:00
parent c99a6a3e4c
commit c183acb800

View File

@ -2,6 +2,7 @@
#include "assert.hh"
#include "buffer_manager.hh"
#include "editor.hh"
namespace Kakoune
{
@ -12,7 +13,7 @@ static Buffer& get_or_create_debug_buffer()
Buffer* buffer = BufferManager::instance().get_buffer(debug_buffer_name);
if (not buffer)
buffer = new Buffer(debug_buffer_name, Buffer::Type::Scratch, "\n");
buffer = new Buffer(debug_buffer_name, Buffer::Type::Scratch, "");
assert(buffer);
return *buffer;
@ -21,7 +22,9 @@ static Buffer& get_or_create_debug_buffer()
void write_debug(const std::string& str)
{
Buffer& debug_buffer = get_or_create_debug_buffer();
debug_buffer.modify(Modification::make_insert(debug_buffer.end()-1, str));
Editor editor(debug_buffer);
editor.select(debug_buffer.end());
editor.insert(str);
}
}