mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-24 03:56:32 +03:00
Avoid recursive macro calls
This commit is contained in:
parent
9306a89deb
commit
cf01f0ed7a
@ -453,6 +453,10 @@ void start_or_end_macro_recording(Context& context)
|
||||
|
||||
void replay_macro(Context& context)
|
||||
{
|
||||
static bool running_macro = false;
|
||||
if (running_macro)
|
||||
throw runtime_error("nested macros not supported");
|
||||
|
||||
int count = context.numeric_param();
|
||||
context.input_handler().on_next_key([count](const Key& key, Context& context) mutable {
|
||||
if (key.modifiers == Key::Modifiers::None)
|
||||
@ -460,6 +464,9 @@ void replay_macro(Context& context)
|
||||
memoryview<String> reg_val = RegisterManager::instance()[key.key].values(context);
|
||||
if (not reg_val.empty())
|
||||
{
|
||||
running_macro = true;
|
||||
auto stop_macro = on_scope_end([&] { running_macro = false; });
|
||||
|
||||
scoped_edition edition(context.editor());
|
||||
do { exec_keys(parse_keys(reg_val[0]), context); } while (--count > 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user