context_wrap: create a DynamicSelectionList only when needed
This commit is contained in:
parent
2f9041b842
commit
32e6184210
|
@ -554,16 +554,14 @@ void context_wrap(const CommandParameters& params, Context& context, Func func)
|
||||||
ClientManager::instance().get_client_context(parser.option_value("client"))
|
ClientManager::instance().get_client_context(parser.option_value("client"))
|
||||||
: context;
|
: context;
|
||||||
|
|
||||||
const bool restore_selections = parser.has_option("restore-selections");
|
if (parser.has_option("restore-selections"))
|
||||||
|
{
|
||||||
Editor& editor = real_context.editor();
|
Editor& editor = real_context.editor();
|
||||||
DynamicSelectionList sels(editor.buffer());
|
DynamicSelectionList sels(editor.buffer(), editor.selections());
|
||||||
if (restore_selections)
|
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
|
||||||
sels = editor.selections();
|
func(parser, real_context);
|
||||||
auto restore_editor = on_scope_end([&]{
|
}
|
||||||
if (restore_selections)
|
else
|
||||||
editor.select(sels);
|
|
||||||
});
|
|
||||||
|
|
||||||
func(parser, real_context);
|
func(parser, real_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user