context_wrap: create a DynamicSelectionList only when needed

This commit is contained in:
Maxime Coste 2013-02-07 19:25:07 +01:00
parent 2f9041b842
commit 32e6184210

View File

@ -554,17 +554,15 @@ void context_wrap(const CommandParameters& params, Context& context, Func func)
ClientManager::instance().get_client_context(parser.option_value("client"))
: context;
const bool restore_selections = parser.has_option("restore-selections");
Editor& editor = real_context.editor();
DynamicSelectionList sels(editor.buffer());
if (restore_selections)
sels = editor.selections();
auto restore_editor = on_scope_end([&]{
if (restore_selections)
editor.select(sels);
});
func(parser, real_context);
if (parser.has_option("restore-selections"))
{
Editor& editor = real_context.editor();
DynamicSelectionList sels(editor.buffer(), editor.selections());
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
func(parser, real_context);
}
else
func(parser, real_context);
}
void exec_string(const CommandParameters& params, Context& context)