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
This commit is contained in:
parent
600be827b3
commit
246a32797a
|
@ -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();
|
||||
|
|
1
test/regression/3799-incorrect-region-match/cmd
Normal file
1
test/regression/3799-incorrect-region-match/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
|
4
test/regression/3799-incorrect-region-match/in
Normal file
4
test/regression/3799-incorrect-region-match/in
Normal file
|
@ -0,0 +1,4 @@
|
|||
print << "";
|
||||
part of heredoc
|
||||
|
||||
not part of heredoc
|
2
test/regression/3799-incorrect-region-match/rc
Normal file
2
test/regression/3799-incorrect-region-match/rc
Normal file
|
@ -0,0 +1,2 @@
|
|||
add-highlighter global/regions regions
|
||||
add-highlighter global/regions/heredoc region -match-capture <<\h*"(\w*)" ^(\w*)$ fill red
|
2
test/regression/3799-incorrect-region-match/script
Normal file
2
test/regression/3799-incorrect-region-match/script
Normal file
|
@ -0,0 +1,2 @@
|
|||
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
|
||||
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "p" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "rint " }, { "face": { "fg": "red", "bg": "default", "attributes": [] }, "contents": "<< \"\";\u000a" }], [{ "face": { "fg": "red", "bg": "default", "attributes": [] }, "contents": "part of heredoc\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "not part of heredoc\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }'
|
Loading…
Reference in New Issue
Block a user