diff --git a/src/commands.cc b/src/commands.cc index c16d5dd9..f711a525 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -340,7 +340,12 @@ const CommandDesc write_cmd = { void write_all_buffers() { + // Copy buffer list because hooks might be creating/deleting buffers + Vector> buffers; for (auto& buffer : BufferManager::instance()) + buffers.emplace_back(buffer.get()); + + for (auto& buffer : buffers) { if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified() and !(buffer->flags() & Buffer::Flags::ReadOnly))