summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 12843565..5f0512d7 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -764,7 +764,6 @@ void insert_output(Context& context, NormalParams params)
auto& selections = context.selections();
auto& buffer = context.buffer();
const size_t old_main = selections.main_index();
- Vector<BufferRange> ins_range;
selections.for_each([&](size_t index, Selection& sel) {
selections.set_main_index(index);
@@ -772,16 +771,13 @@ void insert_output(Context& context, NormalParams params)
cmdline, context, content(context.buffer(), sel),
ShellManager::Flags::WaitForStdout);
+ auto& min = sel.min();
+ auto& max = sel.max();
auto range = insert(buffer, sel, paste_pos(buffer, sel, mode, false), out);
- ins_range.push_back(range);
+ min = range.begin;
+ max = range.end > range.begin ? buffer.char_prev(range.end) : range.begin;
});
-
- selections.set(ins_range | transform([&buffer](auto& range) {
- if (range.empty())
- return Selection{range.begin, range.end};
- return Selection{range.begin,
- buffer.char_prev(range.end)};
- }) | gather<Vector>(), old_main);
+ selections.set_main_index(old_main);
});
}