1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 17:02:06 +03:00

Regex: Fix lookaround use in moon.kak

(?=[A-Z]\w*) is strictly the same as (?=[A-Z]) as \w* will always
at least match an empty string.
This commit is contained in:
Maxime Coste 2017-10-09 11:20:05 +08:00
parent cca730193c
commit 9305fa1369
2 changed files with 7 additions and 4 deletions

View File

@ -1067,13 +1067,13 @@ auto test_regex = UnitTest{[]{
}
{
TestVM<> vm{R"((?!foo)...)"};
TestVM<> vm{R"((?!f[oa]o)...)"};
kak_assert(not vm.exec("foo"));
kak_assert(vm.exec("qux"));
}
{
TestVM<> vm{R"(...(?<=foo))"};
TestVM<> vm{R"(...(?<=f.o))"};
kak_assert(vm.exec("foo"));
kak_assert(not vm.exec("qux"));
}

View File

@ -388,8 +388,11 @@ private:
auto cp = (look_direction == MatchDirection::Forward ? *pos : *(pos-1)), ref = *it;
if (ref == 0xF000)
{} // any character matches
else if (ref > 0xF0000 and ref <= 0xFFFFD and not m_program.matchers[ref - 0xF0001](cp))
return false;
else if (ref > 0xF0000 and ref <= 0xFFFFD)
{
if (not m_program.matchers[ref - 0xF0001](cp))
return false;
}
else if (ref != cp)
return false;