From c0bc7b6644076d1cb6c387ef29a9ad3c8d8acd67 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 23 Jan 2014 19:21:00 +0000 Subject: [PATCH] write_debug: fallback to stderr if the BufferManager does not exists yet fixes #40 --- src/debug.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 61bc7116..7d68fb5b 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -7,8 +7,14 @@ namespace Kakoune { -static Buffer& get_or_create_debug_buffer() +void write_debug(const String& str) { + if (not BufferManager::has_instance()) + { + fprintf(stderr, "%s\n", str.c_str()); + return; + } + static const String debug_buffer_name("*debug*"); Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name); @@ -16,13 +22,7 @@ static Buffer& get_or_create_debug_buffer() buffer = new Buffer(debug_buffer_name, Buffer::Flags::NoUndo); kak_assert(buffer); - return *buffer; -} - -void write_debug(const String& str) -{ - Buffer& buffer = get_or_create_debug_buffer(); - buffer.insert(buffer.end(), str); + buffer->insert(buffer->end(), str); } }