summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.c b/main.c
index 71c7938..5df9e37 100644
--- a/main.c
+++ b/main.c
@@ -681,9 +681,10 @@ int search_next_regex(TxtLoc l, Str src, TxtLoc *out) {
return 0;
}
int match_found = 0;
-search_from_start:
+search_from_start:;
TxtLoc t = l;
re_search_start(&s, &re, &e.scratch);
+ if (at_start(t) || txt_chr(cprev(t)) == '\n') re_search_first_chunk(&s);
while (!at_end(t)) {
Str chnk = txt_next_chunk(&t);
re_search_chunk(&s, chnk.s, chnk.n);
@@ -720,6 +721,7 @@ search_from_end:
Arena a = e.scratch;
re_search_start(&s, &re, &e.scratch);
TxtLoc t = l;
+ if (at_start(t) || txt_chr(cprev(t)) == '\n') re_search_first_chunk(&s);
while (!at_end(t)) {
TxtLoc p = t;
Str chnk = txt_next_chunk(&t);