diff --git a/src/commands.cc b/src/commands.cc index 7c41ba16..febc8f33 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1662,16 +1662,16 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) update_selections(new_sels, main, c.buffer(), timestamp); timestamp = c.buffer().timestamp(); + if (&sel == &sels.main()) + main = new_sels.size() + c.selections().main_index(); + for (auto& sel : c.selections()) new_sels.push_back(sel); } } if (not draft) - { - c.selections_write_only() = SelectionList(c.buffer(), std::move(new_sels)); - c.selections().sort_and_merge_overlapping(); - } + c.selections_write_only().set(std::move(new_sels), main); } else { diff --git a/test/regression/0-assert-on-itersel/cmd b/test/regression/0-assert-on-itersel/cmd new file mode 100644 index 00000000..79801d67 --- /dev/null +++ b/test/regression/0-assert-on-itersel/cmd @@ -0,0 +1 @@ +:exec -itersel jj diff --git a/test/regression/0-assert-on-itersel/in b/test/regression/0-assert-on-itersel/in new file mode 100644 index 00000000..a4cead9b --- /dev/null +++ b/test/regression/0-assert-on-itersel/in @@ -0,0 +1,3 @@ +line %(1) +%(l)ine 2 +line 3 diff --git a/test/regression/0-assert-on-itersel/selections b/test/regression/0-assert-on-itersel/selections new file mode 100644 index 00000000..c0b5ef40 --- /dev/null +++ b/test/regression/0-assert-on-itersel/selections @@ -0,0 +1 @@ +l:3