do_select: do not propagate errors on incremental search

This commit is contained in:
Maxime Coste 2012-12-11 18:46:20 +01:00
parent 892b65b355
commit e36bc74f43

View File

@ -137,6 +137,8 @@ void do_search(Context& context)
SelectionList selections = context.editor().selections(); SelectionList selections = context.editor().selections();
context.input_handler().prompt("/", complete_nothing, context.input_handler().prompt("/", complete_nothing,
[selections](const String& str, PromptEvent event, Context& context) { [selections](const String& str, PromptEvent event, Context& context) {
try
{
context.editor().select(selections); context.editor().select(selections);
if (str.empty() or event == PromptEvent::Abort) if (str.empty() or event == PromptEvent::Abort)
@ -151,7 +153,18 @@ void do_search(Context& context)
RegisterManager::instance()['/'] = ex; RegisterManager::instance()['/'] = ex;
context.push_jump(); 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); }, context);
} }