From c94b343c65b2fb0681be9e2008aabc3fd122bef3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 9 Oct 2014 18:55:58 +0100 Subject: [PATCH] Start regex search from selection min/max depending on search direction --- src/selectors.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;