diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-04-12 12:49:19 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-04-12 12:49:19 +1000 |
| commit | 90db664635013f6e857ec696403f2164032410a8 (patch) | |
| tree | 9b46162cbdb49f10133f92fd92e381ae9b4970b8 /src/input_handler.cc | |
| parent | b2c6bc46901368a1c30d47bd7718c2e10bc69480 (diff) | |
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
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 8adbbcee..26d255c0 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -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) |
