Add new buffers at the back of the buffer list

This will be reverted if we discover why we were doing things the
over way around.

Fixes #1881
This commit is contained in:
Maxime Coste 2018-04-05 10:31:41 +10:00
parent f018a29b58
commit 21603983c5

View File

@ -36,15 +36,14 @@ Buffer* BufferManager::create_buffer(String name, Buffer::Flags flags,
throw runtime_error{"buffer name is already in use"}; throw runtime_error{"buffer name is already in use"};
} }
m_buffers.emplace(m_buffers.begin(), m_buffers.push_back(std::make_unique<Buffer>(std::move(name), flags, data, fs_timestamp));
new Buffer{std::move(name), flags, data, fs_timestamp}); auto* buffer = m_buffers.back().get();
auto& buffer = *m_buffers.front(); buffer->on_registered();
buffer.on_registered();
if (contains(m_buffer_trash, &buffer)) if (contains(m_buffer_trash, buffer))
throw runtime_error{"Buffer got removed during its creation"}; throw runtime_error{"Buffer got removed during its creation"};
return &buffer; return buffer;
} }
void BufferManager::delete_buffer(Buffer& buffer) void BufferManager::delete_buffer(Buffer& buffer)
@ -86,7 +85,7 @@ Buffer& BufferManager::get_first_buffer()
if (all_of(m_buffers, [](auto& b) { return (b->flags() & Buffer::Flags::Debug); })) if (all_of(m_buffers, [](auto& b) { return (b->flags() & Buffer::Flags::Debug); }))
create_buffer("*scratch*", Buffer::Flags::None); create_buffer("*scratch*", Buffer::Flags::None);
return *m_buffers.front(); return *m_buffers.back();
} }
void BufferManager::backup_modified_buffers() void BufferManager::backup_modified_buffers()