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)
|
{
|
||||||
|
case PromptEvent::Change:
|
||||||
|
if (not incsearch or str.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event == PromptEvent::Validate)
|
|
||||||
context.push_jump();
|
|
||||||
else
|
|
||||||
RegisterManager::instance()[reg].restore(context, saved_reg);
|
|
||||||
|
|
||||||
if (not str.empty() and event == PromptEvent::Change) // Ensure search register based highlighters work incrementally
|
|
||||||
RegisterManager::instance()[reg].set(context, str.str());
|
RegisterManager::instance()[reg].set(context, str.str());
|
||||||
|
func(Regex{str, direction_flags(mode)}, event, context);
|
||||||
if (not str.empty() or event == PromptEvent::Validate)
|
return;
|
||||||
|
case PromptEvent::Abort:
|
||||||
|
RegisterManager::instance()[reg].restore(context, saved_reg);
|
||||||
|
return;
|
||||||
|
case 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