diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-10-28 13:28:15 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-10-28 13:43:04 +0800 |
| commit | 43d470f28684154d698002cf4e1ce5f3927e186f (patch) | |
| tree | a4a0354671a7b2a6b2bb947e3b762d07bb81e561 /src/selectors.cc | |
| parent | c8257a58a5564c64e680fb89559b46da354a7d1c (diff) | |
Slight cleanup of select_surrounding implementation
Diffstat (limited to 'src/selectors.cc')
| -rw-r--r-- | src/selectors.cc | 22 |
1 files changed, 6 insertions, 16 deletions
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<Iterator> find_closing(Iterator pos, Iterator end, return {}; } -template<typename Iterator> +template<typename Container, typename Iterator> Optional<std::pair<Iterator, Iterator>> -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<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<Iterator, Iterator>{last, first}; } -template<typename Container, typename Iterator> -Optional<std::pair<Iterator, Iterator>> -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<Selection> select_surrounding(const Context& context, const Selection& selection, StringView opening, StringView closing, int level, |
