diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-07-22 20:05:42 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-07-22 20:26:39 +1000 |
| commit | e42c81c8eb53a6562f0d7313a6a9a92d8360238f (patch) | |
| tree | 2d3ef40e454c17b8fc248492d6e918334bb98d57 /src/context.cc | |
| parent | 837416ea389585a812fc789580e028163bd6bebe (diff) | |
Ensure current context switches away from buffer on delete-buffer
Fixes #3025
Diffstat (limited to 'src/context.cc')
| -rw-r--r-- | src/context.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/context.cc b/src/context.cc index d969ffd0..2a0822ec 100644 --- a/src/context.cc +++ b/src/context.cc @@ -3,6 +3,7 @@ #include "alias_registry.hh" #include "client.hh" #include "face_registry.hh" +#include "buffer_manager.hh" #include "register_manager.hh" #include "window.hh" @@ -171,6 +172,12 @@ void Context::change_buffer(Buffer& buffer) if (has_buffer() and m_edition_level > 0) this->buffer().commit_undo_group(); + if (has_buffer()) + { + auto* current = &this->buffer(); + m_last_buffer = contains(BufferManager::instance(), current) ? current : nullptr; + } + m_window.reset(); if (has_client()) { @@ -185,6 +192,21 @@ void Context::change_buffer(Buffer& buffer) input_handler().reset_normal_mode(); } +void Context::forget_buffer(Buffer& buffer) +{ + m_jump_list.forget_buffer(buffer); + if (m_last_buffer.get() == &buffer) + m_last_buffer = nullptr; + + if (&this->buffer() != &buffer) + return; + + if (is_editing() && has_input_handler()) + input_handler().reset_normal_mode(); + + change_buffer(m_last_buffer ? *m_last_buffer : BufferManager::instance().get_first_buffer()); +} + SelectionList& Context::selections() { if (not m_selections) |
