From e36bc74f431e2f98f049724536da86af9051811d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 11 Dec 2012 18:46:20 +0100 Subject: [PATCH] do_select: do not propagate errors on incremental search --- src/main.cc | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/main.cc b/src/main.cc index b94d4821..a6ffbacf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -137,21 +137,34 @@ void do_search(Context& context) SelectionList selections = context.editor().selections(); context.input_handler().prompt("/", complete_nothing, [selections](const String& str, PromptEvent event, Context& context) { - context.editor().select(selections); - - if (str.empty() or event == PromptEvent::Abort) - return; - - String ex = str; - if (event == PromptEvent::Validate) + try { - if (ex.empty()) - ex = RegisterManager::instance()['/'].values(context)[0]; - else - RegisterManager::instance()['/'] = ex; - context.push_jump(); + context.editor().select(selections); + + if (str.empty() or event == PromptEvent::Abort) + return; + + String ex = str; + if (event == PromptEvent::Validate) + { + if (ex.empty()) + ex = RegisterManager::instance()['/'].values(context)[0]; + else + RegisterManager::instance()['/'] = ex; + context.push_jump(); + } + + context.editor().select(std::bind(select_next_match, _1, ex), mode); } - context.editor().select(std::bind(select_next_match, _1, ex), mode); + catch (runtime_error&) + { + context.editor().select(selections); + // only validation should propagate errors, + // incremental search should not. + if (event == PromptEvent::Validate) + throw; + } + }, context); }