From fbc6bb06953868562c8cac805c0997cd3a8e8ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 23 Jan 2020 14:46:30 +0100 Subject: text: fix search wrapping for overlapping matches Previously, searches wrapping around did not report any results if they started from within the eventual match. Fix this by enlarging the search area to the whole text after reaching the first boundary. See also #787. --- text-motions.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/text-motions.c b/text-motions.c index 97a7e1e..067c9c8 100644 --- a/text-motions.c +++ b/text-motions.c @@ -624,9 +624,7 @@ size_t text_search_forward(Text *txt, size_t pos, Regex *regex) { if (!found) { start = 0; - end = pos; - flags = text_byte_get(txt, end, &c) && c == '\n' ? 0 : REG_NOTEOL; - found = !text_search_range_forward(txt, start, end - start, regex, 1, match, flags); + found = !text_search_range_forward(txt, start, end - start, regex, 1, match, 0); } return found ? match[0].start : pos; @@ -641,10 +639,8 @@ size_t text_search_backward(Text *txt, size_t pos, Regex *regex) { bool found = !text_search_range_backward(txt, start, end, regex, 1, match, flags); if (!found) { - start = pos + 1; end = text_size(txt); - flags = text_byte_get(txt, pos, &c) && c == '\n' ? 0 : REG_NOTBOL; - found = start < end && !text_search_range_backward(txt, start, end - start, regex, 1, match, flags); + found = !text_search_range_backward(txt, start, end - start, regex, 1, match, 0); } return found ? match[0].start : pos; -- cgit v1.2.3