Code style tweak in insert_output

This commit is contained in:
Maxime Coste 2019-12-14 09:20:01 +11:00
parent 32157a5809
commit 874717885a

View File

@ -638,22 +638,15 @@ void insert_output(Context& context, NormalParams)
return; return;
ScopedEdition edition(context); ScopedEdition edition(context);
Buffer& buffer = context.buffer();
auto& shell_manager = ShellManager::instance();
auto& selections = context.selections(); auto& selections = context.selections();
Vector<String> ins;
const size_t old_main = selections.main_index(); const size_t old_main = selections.main_index();
for (size_t i = 0; i < selections.size(); i++) auto ins = selections | transform([&, i=0](auto& sel) mutable {
{ selections.set_main_index(i++);
selections.set_main_index(i); return ShellManager::instance().eval(
cmdline, context, content(context.buffer(), sel),
auto& sel = selections.main();
auto str = shell_manager.eval(cmdline, context, content(buffer, sel),
ShellManager::Flags::WaitForStdout).first; ShellManager::Flags::WaitForStdout).first;
}) | gather<Vector>();
ins.emplace_back(str);
}
selections.set_main_index(old_main); selections.set_main_index(old_main);
selections.insert(ins, mode); selections.insert(ins, mode);