do_select: do not propagate errors on incremental search
This commit is contained in:
parent
892b65b355
commit
e36bc74f43
39
src/main.cc
39
src/main.cc
|
@ -137,21 +137,34 @@ 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) {
|
||||||
context.editor().select(selections);
|
try
|
||||||
|
|
||||||
if (str.empty() or event == PromptEvent::Abort)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String ex = str;
|
|
||||||
if (event == PromptEvent::Validate)
|
|
||||||
{
|
{
|
||||||
if (ex.empty())
|
context.editor().select(selections);
|
||||||
ex = RegisterManager::instance()['/'].values(context)[0];
|
|
||||||
else
|
if (str.empty() or event == PromptEvent::Abort)
|
||||||
RegisterManager::instance()['/'] = ex;
|
return;
|
||||||
context.push_jump();
|
|
||||||
|
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);
|
}, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user