From 1e29608c7e1f7d0864fdb1ef568e56a7ebb01ccd Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 6 Jun 2021 22:34:52 +0200 Subject: [PATCH] Fix positioning of matches in search::search(). --- src/search.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 265aff4..802e15c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -96,6 +96,7 @@ std::vector search(const fs::path &filepath, string::const_iterator begin{file.text.begin()}; string::const_iterator end{file.text.end()}; + auto begin_text{begin}; boost::match_results match_result; while (boost::regex_search(begin, end, match_result, re, @@ -107,12 +108,12 @@ std::vector search(const fs::path &filepath, match.text = match_result[0]; match.context = context(match_result, opts.context); const auto pos = static_cast( - std::distance(begin, match_result[0].begin())); + std::distance(begin_text, match_result[0].begin())); match.headline = headline(file, pos); match.page = page(file, pos); matches.emplace_back(match); - begin = match_result[0].second; + begin = match_result[0].end(); } }