From 29130a2b0a52e3375593fd14c5dcc0b549baaa8a Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Thu, 1 Jan 2026 17:45:03 -0500 Subject: hopefully fix invalid TxtLoc after some searches --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 479235a..d511084 100644 --- a/main.c +++ b/main.c @@ -648,7 +648,8 @@ search_from_start: if (at_end(t)) re_search_last_chunk(&s); ReMatch m; if (re_search_match(&s, &m)) { - *out = (TxtLoc) { p.t, p.p, p.i + m.extent.start }; + while (m.extent.start--) p = bnext(p); + *out = p; return 1; } } @@ -682,8 +683,8 @@ search_from_end: Str chnk = txt_next_chunk(&t); re_search_chunk(&s, chnk.s, chnk.n); if (at_end(t)) re_search_last_chunk(&s); - if (re_search_match_at_start(&s, &m) && m.extent.start == 0) { - *out = (TxtLoc) { p.t, p.p, p.i + m.extent.start }; + if (re_search_match_at_start(&s, &m)) { + *out = p; return 1; } if (~s.flags & RE_SEARCH_MID_MATCH) { -- cgit v1.2.3