1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 08:51:46 +03:00

Support changing buffer when an edition is in progress

This commit is contained in:
Maxime Coste 2014-10-10 14:00:24 +01:00
parent ab930ccfa8
commit 729e55573f
2 changed files with 15 additions and 3 deletions

View File

@ -170,8 +170,14 @@ void Context::forget_jumps_to_buffer(Buffer& buffer)
void Context::change_buffer(Buffer& buffer)
{
if (&buffer == &this->buffer())
return;
if (m_edition_level > 0)
throw runtime_error("the current buffer is still being edited");
{
this->buffer().commit_undo_group();
m_edition_level = 0;
}
m_window.reset();
if (has_client())
client().change_buffer(buffer);

View File

@ -113,15 +113,21 @@ private:
struct ScopedEdition
{
ScopedEdition(Context& context)
: m_context(context)
: m_context(context), m_buffer(&context.buffer())
{ m_context.begin_edition(); }
~ScopedEdition()
{ m_context.end_edition(); }
{
// If buffer changed, the edition count
// was reset.
if (m_buffer == &m_context.buffer())
m_context.end_edition();
}
Context& context() const { return m_context; }
private:
Context& m_context;
safe_ptr<Buffer> m_buffer;
};
}