Refactor write_debug to avoid empty first line in *debug* buffer

This commit is contained in:
Maxime Coste 2015-01-05 09:38:40 +00:00
parent ca9baecd4c
commit c279da14e3

View File

@ -17,13 +17,13 @@ void write_debug(StringView str)
}
const StringView debug_buffer_name = "*debug*";
Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name);
if (not buffer)
buffer = new Buffer(debug_buffer_name, Buffer::Flags::NoUndo);
kak_assert(buffer);
if (Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name))
buffer->insert(buffer->end(), str);
else
{
String line = str + ((str.empty() or str.back() != '\n') ? "\n" : "");
new Buffer(debug_buffer_name, Buffer::Flags::NoUndo, { line });
}
}
}