summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-01-27 10:58:38 +1100
committerMaxime Coste <mawww@kakoune.org>2023-01-27 10:58:38 +1100
commit37b160e935cf88bcc91a151c8b3c300c988a2cdb (patch)
tree1ae40b5ee566ee3cc273def3f5d6803c51cd264f /src
parent9763ce4fe963ea8f10001346bec03cc0cff7f773 (diff)
parentb039a313a457c29710fda077f7e69725afd34976 (diff)
Merge remote-tracking branch 'occivink/fix-split-stray-sel'
Diffstat (limited to 'src')
-rw-r--r--src/selectors.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/selectors.cc b/src/selectors.cc
index 3d9b453d..2c657b80 100644
--- a/src/selectors.cc
+++ b/src/selectors.cc
@@ -965,7 +965,8 @@ Vector<Selection> split_on_matches(const Buffer& buffer, ConstArrayView<Selectio
ThreadedRegexVM<BufferIterator, RegexMode::Forward | RegexMode::Search> vm{*regex.impl()};
for (auto& sel : selections)
{
- auto begin = buffer.iterator_at(sel.min());
+ auto sel_begin = buffer.iterator_at(sel.min());
+ auto begin = sel_begin;
auto sel_end = utf8::next(buffer.iterator_at(sel.max()), buf_end);
for (auto&& match : RegexIterator{begin, sel_end, vm, match_flags(buffer, begin, sel_end)})
@@ -975,7 +976,7 @@ Vector<Selection> split_on_matches(const Buffer& buffer, ConstArrayView<Selectio
if (end == buf_end)
continue;
- if (end != buf_begin)
+ if (end != sel_begin)
{
auto sel_end = (begin == end) ? end : utf8::previous(end, begin);
result.push_back(keep_direction({ begin.coord(), sel_end.coord() }, sel));