diff --git a/src/main.cc b/src/main.cc index 1adbf3e0..68e32262 100644 --- a/src/main.cc +++ b/src/main.cc @@ -184,15 +184,12 @@ void do_pipe(Context& context) { auto cmdline = prompt("|", context, complete_nothing); - context.buffer().begin_undo_group(); + Editor& editor = context.editor(); + std::vector strings; for (auto& sel : const_cast(context.editor()).selections()) - { - String new_content = ShellManager::instance().pipe(String(sel.begin(), sel.end()), - cmdline, context, {}); - context.buffer().modify(Modification::make_erase(sel.begin(), sel.end())); - context.buffer().modify(Modification::make_insert(sel.begin(), new_content)); - } - context.buffer().end_undo_group(); + strings.push_back(ShellManager::instance().pipe(String(sel.begin(), sel.end()), + cmdline, context, {})); + editor.replace(strings); } catch (prompt_aborted&) {} }