From 246a32797a17e7cdebcde64ac98c09501d1da10d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 12 Oct 2020 12:14:01 +1100 Subject: Fix region regexes incorrectly matching ^$ at end of line Because no flags were set for regex matching, the regex engine was assuming that the subject string past-the-end matched a end-of-line. As the subject string already ended with a \n character, the regex engine processing of the "past-the-end" position would match '^$' as ^ matched past the existing \n and $ matched the assumed end-of-line. Fixes #3799 --- src/highlighters.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/highlighters.cc b/src/highlighters.cc index 78099b08..309ade94 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1744,7 +1744,8 @@ void insert_matches(const Buffer& buffer, RegexMatchList& matches, const Regex& for (auto line = range.begin; line < range.end; ++line) { const StringView l = buffer[line]; - for (auto&& m : RegexIterator{l.begin(), l.end(), vm}) + const auto flags = RegexExecFlags::NotEndOfLine; // buffer line already ends with \n + for (auto&& m : RegexIterator{l.begin(), l.end(), vm, flags}) { const bool with_capture = capture and m[1].matched and m[0].second - m[0].first < std::numeric_limits::max(); -- cgit v1.2.3