Fix review findings in the regex engine, search count and journal v2
- PCRE2: compile with the ANYCRLF newline convention and DOLLAR_ENDONLY,
as ECMAScript reads '.' and '$'. With PCRE2's default (LF only) '.'
matched the CR of a CRLF line, so regex replace-all deleted CRs.
- Replacement $0 is the whole match, two digits are read greedily and a
group the pattern lacks expands to nothing, as std::regex_replace
(libstdc++) does; these cases are now compared in the tests.
- Plain search visits overlapping matches going forward too, and counts
them, as the backward search found them ('aa' in 'aaa' read 2/1).
- The recovery prompt's replayed content is used on 'y' only if the
journal is unchanged since; otherwise it is replayed again.
- A version 1 journal continued after recovery is rewritten as a
compacted version 2 journal when it needs a chunked checkpoint,
instead of receiving records an older kte would skip. (The version is
read through a separate descriptor: the journal fd is write-only.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
+4
-2
@@ -1169,7 +1169,7 @@ search_count(const Buffer &buf, bool regex, const std::string &q, const RegexMat
|
||||
else
|
||||
c.reached = true;
|
||||
++c.total;
|
||||
p += q.size();
|
||||
p += 1; // overlapping, as Next/Previous visit them
|
||||
}
|
||||
if (p != std::string_view::npos && p >= cur_off)
|
||||
c.reached = true;
|
||||
@@ -1238,7 +1238,9 @@ run_search(Editor &ed, Buffer &buf, bool regex, SearchStep step, bool incrementa
|
||||
x = ed.SearchOrigX();
|
||||
}
|
||||
if (step == SearchStep::Next && have_cur) {
|
||||
const std::size_t len = std::max<std::size_t>(ed.SearchMatchLen(), 1);
|
||||
// Plain search visits overlapping matches ("aa" in "aaa" at 0 and 1),
|
||||
// as the backward search does; a regex continues after its match.
|
||||
const std::size_t len = regex ? std::max<std::size_t>(ed.SearchMatchLen(), 1) : 1;
|
||||
x += len;
|
||||
if (x > line_text_view(buf, y).size() && y + 1 < buf.Nrows()) {
|
||||
++y;
|
||||
|
||||
Reference in New Issue
Block a user