From ecf8047bcc61ac87e9745f2e8600785972ff84cb Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 25 Sep 2014 13:29:53 +0100 Subject: [PATCH] Fix reverse search when extending --- src/normal.cc | 7 +++++-- src/selectors.hh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 0c749e23..1de74b97 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -421,7 +421,7 @@ void select_next_match(const Buffer& buffer, SelectionList& selections, if (mode == SelectMode::Replace) { for (auto& sel : selections) - sel = find_next_match(buffer, sel, regex); + sel = keep_direction(find_next_match(buffer, sel, regex), sel); } if (mode == SelectMode::Extend) { @@ -430,7 +430,10 @@ void select_next_match(const Buffer& buffer, SelectionList& selections, } else if (mode == SelectMode::Append) { - selections.push_back(find_next_match(buffer, selections.main(), regex)); + auto sel = keep_direction( + find_next_match(buffer, selections.main(), regex), + selections.main()); + selections.push_back(std::move(sel)); selections.set_main_index(selections.size() - 1); } selections.sort_and_merge_overlapping(); diff --git a/src/selectors.hh b/src/selectors.hh index 6382b0da..5107226e 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -281,7 +281,7 @@ Selection find_next_match(const Buffer& buffer, const Selection& sel, const Rege if (direction == Backward) std::swap(begin, end); - return keep_direction({begin.coord(), end.coord(), std::move(captures)}, sel); + return {begin.coord(), end.coord(), std::move(captures)}; } void select_all_matches(SelectionList& selections,