Support changing buffer when an edition is in progress
This commit is contained in:
parent
ab930ccfa8
commit
729e55573f
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user