Refactor regex_prompt logic and fix function being called on abort
Fixes #4993
This commit is contained in:
parent
7be996e5a4
commit
18902b15af
|
@ -854,20 +854,22 @@ void regex_prompt(Context& context, String prompt, char reg, T func)
|
||||||
|
|
||||||
context.input_handler().set_prompt_face(context.faces()["Prompt"]);
|
context.input_handler().set_prompt_face(context.faces()["Prompt"]);
|
||||||
}
|
}
|
||||||
|
switch (event)
|
||||||
if (not incsearch and event == PromptEvent::Change)
|
{
|
||||||
return;
|
case PromptEvent::Change:
|
||||||
|
if (not incsearch or str.empty())
|
||||||
if (event == PromptEvent::Validate)
|
return;
|
||||||
context.push_jump();
|
RegisterManager::instance()[reg].set(context, str.str());
|
||||||
else
|
func(Regex{str, direction_flags(mode)}, event, context);
|
||||||
RegisterManager::instance()[reg].restore(context, saved_reg);
|
return;
|
||||||
|
case PromptEvent::Abort:
|
||||||
if (not str.empty() and event == PromptEvent::Change) // Ensure search register based highlighters work incrementally
|
RegisterManager::instance()[reg].restore(context, saved_reg);
|
||||||
RegisterManager::instance()[reg].set(context, str.str());
|
return;
|
||||||
|
case PromptEvent::Validate:
|
||||||
if (not str.empty() or event == PromptEvent::Validate)
|
context.push_jump();
|
||||||
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
|
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (regex_error& err)
|
catch (regex_error& err)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user