mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 00:42:13 +03:00
Catch std::runtime_errors that can be thrown by regex_search
This handle the case where a regex matching gets too complex.
This commit is contained in:
parent
4010117c98
commit
e4e609a35c
@ -603,6 +603,8 @@ void regex_prompt(Context& context, const String prompt, T func)
|
||||
[=](const String& str, PromptEvent event, Context& context) {
|
||||
try
|
||||
{
|
||||
if (event != PromptEvent::Change and context.has_ui())
|
||||
context.ui().info_hide();
|
||||
context.selections() = selections;
|
||||
context.input_handler().set_prompt_colors(get_color("Prompt"));
|
||||
if (event == PromptEvent::Abort)
|
||||
@ -622,6 +624,22 @@ void regex_prompt(Context& context, const String prompt, T func)
|
||||
else
|
||||
context.input_handler().set_prompt_colors(get_color("Error"));
|
||||
}
|
||||
catch (std::runtime_error& err)
|
||||
{
|
||||
if (event == PromptEvent::Validate)
|
||||
throw runtime_error("regex error: "_str + err.what());
|
||||
else
|
||||
{
|
||||
context.input_handler().set_prompt_colors(get_color("Error"));
|
||||
if (context.has_ui())
|
||||
{
|
||||
ColorPair col = get_color("Information");
|
||||
CharCoord pos = context.window().dimensions();
|
||||
pos.column -= 1;
|
||||
context.ui().info_show("regex error", err.what(), pos, col, MenuStyle::Prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (runtime_error&)
|
||||
{
|
||||
context.selections() = selections;
|
||||
|
Loading…
Reference in New Issue
Block a user