Fix positioning of matches in search::search().
This commit is contained in:
parent
5e89a71e00
commit
1e29608c7e
@ -96,6 +96,7 @@ std::vector<match> search(const fs::path &filepath,
|
|||||||
|
|
||||||
string::const_iterator begin{file.text.begin()};
|
string::const_iterator begin{file.text.begin()};
|
||||||
string::const_iterator end{file.text.end()};
|
string::const_iterator end{file.text.end()};
|
||||||
|
auto begin_text{begin};
|
||||||
boost::match_results<string::const_iterator> match_result;
|
boost::match_results<string::const_iterator> match_result;
|
||||||
|
|
||||||
while (boost::regex_search(begin, end, match_result, re,
|
while (boost::regex_search(begin, end, match_result, re,
|
||||||
@ -107,12 +108,12 @@ std::vector<match> search(const fs::path &filepath,
|
|||||||
match.text = match_result[0];
|
match.text = match_result[0];
|
||||||
match.context = context(match_result, opts.context);
|
match.context = context(match_result, opts.context);
|
||||||
const auto pos = static_cast<size_t>(
|
const auto pos = static_cast<size_t>(
|
||||||
std::distance(begin, match_result[0].begin()));
|
std::distance(begin_text, match_result[0].begin()));
|
||||||
match.headline = headline(file, pos);
|
match.headline = headline(file, pos);
|
||||||
match.page = page(file, pos);
|
match.page = page(file, pos);
|
||||||
|
|
||||||
matches.emplace_back(match);
|
matches.emplace_back(match);
|
||||||
begin = match_result[0].second;
|
begin = match_result[0].end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user