summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-06-07 13:45:03 +1000
committerMaxime Coste <mawww@kakoune.org>2020-06-07 14:12:54 +1000
commit66f15cf4ad8b0127f93503cad41d570a7c9f5d72 (patch)
tree6fe305be866fa34ffaaabfd4a1ba74b03f507b94 /src
parenta56a03c454cd806e01617fb76af7c9ce7e374afc (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/normal.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 8796c86f..beb880f9 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -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();