diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2024-11-03 14:06:48 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-11-04 07:15:34 +1100 |
| commit | 6b9291104b72b678964024d35c3da5f34f86b2cb (patch) | |
| tree | eee785e7ffee50f17e2fa74c1c196e12a68ec9cc /src/regex_impl.cc | |
| parent | 60fcc3443ef199f329a4e5c4fcd94ad017813a9b (diff) | |
Fix backward regex search ending in DOTALL
I noticed that reverse searches ending in "." stopped working in
version 2024.05.08:
kak -n -e "exec %{%cfoobar<ret><esc>gj<a-/>foo.<ret>}'
Bisects ca7471c25 (Compute StartDesc with an offset to effective start,
2024-03-18) which updated the find_next_start() logic for the forward
case but not for backward case. Add a symmetrical change and test
case, that seems to fix it. Not 100% sure if this is correct but
feels so.
Diffstat (limited to 'src/regex_impl.cc')
| -rw-r--r-- | src/regex_impl.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 4b404cfa..d86637cd 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -1594,6 +1594,17 @@ auto test_regex = UnitTest{[]{ } { + TestVM<RegexMode::Backward | RegexMode::Search> vm{"oo(.{3,4}|f)"}; + kak_assert(vm.backward_start_desc and vm.backward_start_desc->offset == 4); + for (int c = 0; c < CompiledRegex::StartDesc::count; ++c) + kak_assert(vm.backward_start_desc->map[c] == (c == 'f' or c == 'o')); + + kak_assert(vm.exec("ooxxx", RegexExecFlags::None)); + kak_assert(vm.exec("oofx", RegexExecFlags::None)); + kak_assert(not vm.exec("oox😄", RegexExecFlags::None)); + } + + { auto eq = [](const CompiledRegex::NamedCapture& lhs, const CompiledRegex::NamedCapture& rhs) { return lhs.name == rhs.name and |
