summaryrefslogtreecommitdiff
path: root/src/keymap_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-05-29 20:08:02 +1000
committerMaxime Coste <mawww@kakoune.org>2023-05-29 20:11:06 +1000
commitcf7c6380254c7c2733952d2899761a2afc881b44 (patch)
tree7e1dd924a2c37fb34063ae7d3e9e2668f036ec2a /src/keymap_manager.cc
parent3069b68245a0bd5451fac33a56097eb7c9351975 (diff)
Refactor KeymapManager to enfore setting is_executing on key iteration
Add an iterator based remove to HashMap as that was missing. Make KeymapManager responsible for throwing on unmap an executing mapping.
Diffstat (limited to 'src/keymap_manager.cc')
-rw-r--r--src/keymap_manager.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/keymap_manager.cc b/src/keymap_manager.cc
index baec1373..81efe7ed 100644
--- a/src/keymap_manager.cc
+++ b/src/keymap_manager.cc
@@ -18,7 +18,12 @@ void KeymapManager::map_key(Key key, KeymapMode mode,
void KeymapManager::unmap_key(Key key, KeymapMode mode)
{
- m_mapping.remove(KeyAndMode{key, mode});
+ auto it = m_mapping.find(KeyAndMode{key, mode});
+ if (it == m_mapping.end())
+ return;
+ if (it->value.is_executing)
+ throw runtime_error("cannot unmap key that is currently executing");
+ m_mapping.remove(it);
}
void KeymapManager::unmap_keys(KeymapMode mode)