Fix regex not always selecting the leftmost longest match
(Actually the rightmost longest match when searching backwards) Fixes #2710
This commit is contained in:
parent
4cb402ac1a
commit
d9d2140ea2
|
@ -1489,6 +1489,12 @@ auto test_regex = UnitTest{[]{
|
||||||
kak_assert(StringView{vm.captures()[0], vm.captures()[1]} == "baz");
|
kak_assert(StringView{vm.captures()[0], vm.captures()[1]} == "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
TestVM<RegexMode::Backward | RegexMode::Search> vm{R"(a[^\n]*\n|\n)"};
|
||||||
|
kak_assert(vm.exec("foo\nbar\nb", RegexExecFlags::None));
|
||||||
|
kak_assert(StringView{vm.captures()[0], vm.captures()[1]} == "ar\n");
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
TestVM<> vm{R"(()*)"};
|
TestVM<> vm{R"(()*)"};
|
||||||
kak_assert(not vm.exec(" "));
|
kak_assert(not vm.exec(" "));
|
||||||
|
|
|
@ -510,7 +510,7 @@ private:
|
||||||
forward ? utf8::to_next(pos, config.subject_end)
|
forward ? utf8::to_next(pos, config.subject_end)
|
||||||
: utf8::to_previous(pos, config.subject_begin);
|
: utf8::to_previous(pos, config.subject_begin);
|
||||||
|
|
||||||
if (search)
|
if (search and not m_found_match)
|
||||||
{
|
{
|
||||||
if (start_desc and m_threads.next_is_empty())
|
if (start_desc and m_threads.next_is_empty())
|
||||||
to_next_start(pos, config, *start_desc);
|
to_next_start(pos, config, *start_desc);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user