diff --git a/src/keymap_manager.cc b/src/keymap_manager.cc index 81efe7ed..26579bf7 100644 --- a/src/keymap_manager.cc +++ b/src/keymap_manager.cc @@ -13,6 +13,9 @@ namespace Kakoune void KeymapManager::map_key(Key key, KeymapMode mode, KeyList mapping, String docstring) { + if (auto it = m_mapping.find(KeyAndMode{key, mode}); it != m_mapping.end()) + if (it->value.is_executing) + throw runtime_error("cannot map key that is currently executing"); m_mapping[KeyAndMode{key, mode}] = {std::move(mapping), std::move(docstring)}; } diff --git a/test/regression/4896-remap-executing-mapping/cmd b/test/regression/4896-remap-executing-mapping/cmd new file mode 100644 index 00000000..a09e364c --- /dev/null +++ b/test/regression/4896-remap-executing-mapping/cmd @@ -0,0 +1,3 @@ +!printf $kak_opt_source_countl +s +!printf $kak_opt_source_count diff --git a/test/regression/4896-remap-executing-mapping/in b/test/regression/4896-remap-executing-mapping/in new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/4896-remap-executing-mapping/in @@ -0,0 +1 @@ + diff --git a/test/regression/4896-remap-executing-mapping/out b/test/regression/4896-remap-executing-mapping/out new file mode 100644 index 00000000..48082f72 --- /dev/null +++ b/test/regression/4896-remap-executing-mapping/out @@ -0,0 +1 @@ +12 diff --git a/test/regression/4896-remap-executing-mapping/rc b/test/regression/4896-remap-executing-mapping/rc new file mode 100644 index 00000000..56624d18 --- /dev/null +++ b/test/regression/4896-remap-executing-mapping/rc @@ -0,0 +1,3 @@ +try %{ map global user s %exp{:source %%{%val{source}}} -docstring "re-source my kakrc" } +declare-option int source_count +set-option -add global source_count 1