From c279da14e3c1dfda6dc5788f5711b2f1ed1b611d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Jan 2015 09:38:40 +0000 Subject: [PATCH] Refactor write_debug to avoid empty first line in *debug* buffer --- src/debug.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 5fa9850b..478feae7 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -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); - buffer->insert(buffer->end(), str); + 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 }); + } } }