diff --git a/src/selectors.hh b/src/selectors.hh index a75fac8a..1cd17b0a 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -267,7 +267,9 @@ Selection find_next_match(const Buffer& buffer, const Selection& sel, const Rege CaptureList captures; MatchResults matches; bool found = false; - if ((found = find_match_in_buffer(buffer, utf8::next(begin, buffer.end()), matches, regex))) + auto pos = direction == Forward ? utf8::next(begin, buffer.end()) + : utf8::previous(begin, buffer.begin()); + if ((found = find_match_in_buffer(buffer, pos, matches, regex))) { begin = matches[0].first; end = matches[0].second;