diff --git a/src/selectors.cc b/src/selectors.cc index a4f8b9d6..5ab25e5d 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -295,7 +295,7 @@ find_surrounding(Iterator begin, Iterator end, const bool nestable = opening != closing; auto first = pos; - if (to_begin) + if (to_begin and opening != *pos) { using RevIt = std::reverse_iterator; auto res = find_closing(RevIt{pos+1}, RevIt{begin},