summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-10-09 18:55:58 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-10-09 18:55:58 +0100
commitc94b343c65b2fb0681be9e2008aabc3fd122bef3 (patch)
treebc12e545a210fe364e2b5007a4b4ae6352ec901b /src
parent7ca095c2b909dc2e2829a04d03912abd443b4a34 (diff)
Start regex search from selection min/max depending on search direction
Diffstat (limited to 'src')
-rw-r--r--src/selectors.hh4
1 files changed, 3 insertions, 1 deletions
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<direction>(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<direction>(buffer, pos, matches, regex)))
{
begin = matches[0].first;
end = matches[0].second;