From 33eb93b6198227f6003f11865a830220d7f4017f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 23 Dec 2016 16:37:54 +0000 Subject: [PATCH] Skip debug buffer when cycling through the buffer list Fixes #1059 --- src/commands.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index f8951e05..63700b12 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -523,22 +523,26 @@ void cycle_buffer(const ParametersParser& parser, Context& context, const ShellC auto it = find_if(BufferManager::instance(), [oldbuf](const std::unique_ptr& lhs) { return lhs.get() == oldbuf; }); - kak_assert(it != BufferManager::instance().end()); - if (not next) - { - if (it == BufferManager::instance().begin()) - it = BufferManager::instance().end(); - --it; - } - else - { - if (++it == BufferManager::instance().end()) - it = BufferManager::instance().begin(); - } - - Buffer* newbuf = it->get(); + Buffer* newbuf = nullptr; + auto cycle = [&] { + if (not next) + { + if (it == BufferManager::instance().begin()) + it = BufferManager::instance().end(); + --it; + } + else + { + if (++it == BufferManager::instance().end()) + it = BufferManager::instance().begin(); + } + newbuf = it->get(); + }; + cycle(); + if (newbuf->flags() & Buffer::Flags::Debug) + cycle(); if (newbuf != oldbuf) {