1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 12:36:11 +03:00

Fix crash when deleting a buffer from a user mapping

Deleting a buffer resets normal mode on all clients that were
displaing that buffer, but ScopedForceNormalMode that are used
from user mode  do not take this possiblity into account on
destruction, which leads to deleting the last normal mode from
the context, ending up with an empty mode stack.

Fixes #3909
This commit is contained in:
Maxime Coste 2022-04-12 12:49:19 +10:00
parent b2c6bc4690
commit 90db664635
6 changed files with 9 additions and 9 deletions

View File

@ -1698,14 +1698,9 @@ InputHandler::ScopedForceNormal::~ScopedForceNormal()
if (m_mode == m_handler.m_mode_stack.back().get())
m_handler.pop_mode(m_mode);
else
{
auto it = find_if(m_handler.m_mode_stack,
[this](const RefPtr<InputMode>& m)
{ return m.get() == m_mode; });
kak_assert(it != m_handler.m_mode_stack.end());
else if (auto it = find(m_handler.m_mode_stack, m_mode);
it != m_handler.m_mode_stack.end())
m_handler.m_mode_stack.erase(it);
}
}
static bool is_valid(Key key)

View File

@ -88,8 +88,8 @@ struct RefPtr
acquire();
}
friend bool operator==(const RefPtr& lhs, const RefPtr& rhs) { return lhs.m_ptr == rhs.m_ptr; }
friend bool operator!=(const RefPtr& lhs, const RefPtr& rhs) { return lhs.m_ptr != rhs.m_ptr; }
friend bool operator==(const RefPtr& lhs, const RefPtr& rhs) = default;
friend bool operator==(const RefPtr& lhs, const T* rhs) { return lhs.m_ptr == rhs; }
private:
T* m_ptr = nullptr;

View File

@ -0,0 +1 @@
i<a-;>,d<esc>

View File

@ -0,0 +1,2 @@
edit -scratch
map global user d :delete-buffer<ret>