summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-10-12 12:14:01 +1100
committerMaxime Coste <mawww@kakoune.org>2020-10-12 12:41:21 +1100
commit246a32797a17e7cdebcde64ac98c09501d1da10d (patch)
tree070a743669449d9b35605abc707dee727bb65d56 /src
parent600be827b378444ed548492328a041a0b5154a70 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc3
1 files changed, 2 insertions, 1 deletions
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<uint16_t>::max();