diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 8742e19c..1ff73472 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -1489,6 +1489,12 @@ auto test_regex = UnitTest{[]{ kak_assert(StringView{vm.captures()[0], vm.captures()[1]} == "baz"); } + { + TestVM 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"(()*)"}; kak_assert(not vm.exec(" ")); diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 962fbf61..ee374429 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -510,7 +510,7 @@ private: forward ? utf8::to_next(pos, config.subject_end) : 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()) to_next_start(pos, config, *start_desc);