context_wrap: create a DynamicSelectionList only when needed
This commit is contained in:
parent
2f9041b842
commit
32e6184210
|
@ -554,17 +554,15 @@ 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();
|
{
|
||||||
DynamicSelectionList sels(editor.buffer());
|
Editor& editor = real_context.editor();
|
||||||
if (restore_selections)
|
DynamicSelectionList sels(editor.buffer(), editor.selections());
|
||||||
sels = editor.selections();
|
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
|
||||||
auto restore_editor = on_scope_end([&]{
|
func(parser, real_context);
|
||||||
if (restore_selections)
|
}
|
||||||
editor.select(sels);
|
else
|
||||||
});
|
func(parser, real_context);
|
||||||
|
|
||||||
func(parser, real_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_string(const CommandParameters& params, Context& context)
|
void exec_string(const CommandParameters& params, Context& context)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user