From e8ad943532f2211dcbaeb2e75f71ef2f6516dd7f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 19 Apr 2024 17:04:41 +1000 Subject: [PATCH] Ensure re-used fifo buffers makes that buffer the latest opened --- src/buffer_manager.cc | 7 +++++++ src/buffer_manager.hh | 1 + src/buffer_utils.cc | 1 + 3 files changed, 9 insertions(+) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 447b47c1..35f0fcde 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -149,4 +149,11 @@ void BufferManager::arrange_buffers(ConstArrayView first_ones) m_buffers = std::move(res); } +void BufferManager::make_latest(Buffer& buffer) +{ + auto it = find(m_buffers, &buffer); + kak_assert(it != m_buffers.end()); + std::rotate(it, it+1, m_buffers.end()); +} + } diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh index 78fb4c89..5b687a7f 100644 --- a/src/buffer_manager.hh +++ b/src/buffer_manager.hh @@ -31,6 +31,7 @@ public: Buffer* get_buffer_matching_ifp(const Regex& regex); Buffer& get_buffer_matching(const Regex& regex); + void make_latest(Buffer& buffer); void arrange_buffers(ConstArrayView first_ones); Buffer& get_first_buffer(); diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 76910483..6a66b000 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -176,6 +176,7 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll buffer->flags() |= Buffer::Flags::NoUndo | flags; buffer->values().clear(); buffer->reload({StringData::create("\n")}, ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}}); + buffer_manager.make_latest(*buffer); } else buffer = buffer_manager.create_buffer(