Fix select wiping captures

It turns out `v = std::move(v)` with v a std::vector is not a no-op,
it clears the vector.
This commit is contained in:
Maxime Coste 2020-06-07 13:45:03 +10:00
parent a56a03c454
commit 66f15cf4ad
4 changed files with 9 additions and 4 deletions

View File

@ -93,7 +93,7 @@ void select(Context& context, T func)
else
{
auto main_index = selections.main_index();
auto new_end = selections.begin();
size_t new_size = 0;
for (size_t i = 0; i < selections.size(); ++i)
{
auto& sel = selections[i];
@ -114,13 +114,15 @@ void select(Context& context, T func)
}
if (not res->captures().empty())
sel.captures() = std::move(res->captures());
*new_end++ = std::move(sel);
if (i != new_size)
selections[new_size] = std::move(sel);
++new_size;
}
if (new_end == selections.begin())
if (new_size == 0)
throw no_selections_remaining{};
selections.set_main_index(main_index);
selections.remove_from(new_end - selections.begin());
selections.remove_from(new_size);
}
selections.sort_and_merge_overlapping();

View File

@ -0,0 +1 @@
/(a)<ret>xcx<c-r>1x<esc>

View File

@ -0,0 +1 @@
xax

View File

@ -0,0 +1 @@
xax