Small cleanup in BufferManager code

This commit is contained in:
Maxime Coste 2016-11-29 19:12:10 +00:00
parent 168abcdb48
commit db86c6cbc9
2 changed files with 6 additions and 11 deletions

View File

@ -11,11 +11,6 @@
namespace Kakoune
{
struct name_not_unique : runtime_error
{
name_not_unique() : runtime_error("buffer name is already in use") {}
};
BufferManager::~BufferManager()
{
// Move buffers to m_buffer_trash to avoid running BufClose
@ -37,7 +32,7 @@ Buffer* BufferManager::create_buffer(String name, Buffer::Flags flags,
{
if (buf->name() == name or
(buf->flags() & Buffer::Flags::File and buf->name() == path))
throw name_not_unique();
throw runtime_error{"buffer name is already in use"};
}
m_buffers.emplace(m_buffers.begin(),
@ -46,7 +41,7 @@ Buffer* BufferManager::create_buffer(String name, Buffer::Flags flags,
buffer.on_registered();
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;
}
@ -81,7 +76,7 @@ Buffer& BufferManager::get_buffer(StringView name)
{
Buffer* res = get_buffer_ifp(name);
if (not res)
throw runtime_error(format("no such buffer '{}'", name));
throw runtime_error{format("no such buffer '{}'", name)};
return *res;
}

View File

@ -2,9 +2,9 @@
#define buffer_manager_hh_INCLUDED
#include "buffer.hh"
#include "completion.hh"
#include "utils.hh"
#include "safe_ptr.hh"
#include "vector.hh"
#include <memory>
namespace Kakoune
{