vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 89c2239486233fc3eea0e02a1dbcddcaa57f44d9 parent bcb86378e81e931220dc3abb9f857afbf68f312a Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 23 Jan 2020 14:46:30 +0100 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. Diffstat:
| M | text-motions.c | | | 8 | ++------ |
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git 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;