diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-05-08 19:33:14 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-05-08 19:33:14 +0100 |
| commit | e4e609a35c6a5e45d495c5d2e0f99dd4c6dc33fb (patch) | |
| tree | 215706b086b31c6133585cadbef24db54acdcd6d /src/normal.cc | |
| parent | 4010117c983712926b028b4d6f37e6a0600b0105 (diff) | |
Catch std::runtime_errors that can be thrown by regex_search
This handle the case where a regex matching gets too complex.
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/normal.cc b/src/normal.cc index c856ebe7..1b1f9152 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -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; |
