diff --git a/src/selectors.cc b/src/selectors.cc index 417294ed..e751de41 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -314,12 +314,13 @@ Optional find_closing(Iterator pos, Iterator end, return {}; } -template +template Optional> -find_surrounding(Iterator begin, Iterator end, - Iterator pos, StringView opening, StringView closing, +find_surrounding(const Container& container, Iterator pos, + StringView opening, StringView closing, ObjectFlags flags, int init_level) { + using std::begin; using std::end; const bool to_begin = flags & ObjectFlags::ToBegin; const bool to_end = flags & ObjectFlags::ToEnd; const bool nestable = opening != closing; @@ -328,7 +329,7 @@ find_surrounding(Iterator begin, Iterator end, if (to_begin and opening != *pos) { using RevIt = std::reverse_iterator; - auto res = find_closing(RevIt{pos+1}, RevIt{begin}, + auto res = find_closing(RevIt{pos+1}, RevIt{begin(container)}, closing | reverse(), opening | reverse(), init_level, nestable); if (not res) @@ -340,7 +341,7 @@ find_surrounding(Iterator begin, Iterator end, auto last = pos; if (to_end) { - auto res = find_closing(pos, end, opening, closing, + auto res = find_closing(pos, end(container), opening, closing, init_level, nestable); if (not res) return {}; @@ -359,17 +360,6 @@ find_surrounding(Iterator begin, Iterator end, : std::pair{last, first}; } -template -Optional> -find_surrounding(const Container& container, Iterator pos, - StringView opening, StringView closing, - ObjectFlags flags, int init_level) -{ - using std::begin; using std::end; - return find_surrounding(begin(container), end(container), pos, - opening, closing, flags, init_level); -} - Optional select_surrounding(const Context& context, const Selection& selection, StringView opening, StringView closing, int level, diff --git a/src/selectors.hh b/src/selectors.hh index 9d4f98dc..e2c3444e 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -109,8 +109,8 @@ void split_selections(SelectionList& selections, const Regex& regex, int capture Optional select_surrounding(const Context& context, const Selection& selection, - StringView opening, StringView closing, int level, - ObjectFlags flags); + StringView opening, StringView closing, int level, + ObjectFlags flags); }