diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-01-23 14:46:30 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-01-23 14:46:30 +0100 |
| commit | fbc6bb06953868562c8cac805c0997cd3a8e8ef9 (patch) | |
| tree | 007bce76092b38364ac3f2247cd0555c8295a1f9 /text-motions.c | |
| parent | 886a5ed603df862a26f0d6d78d6c8dd161623738 (diff) | |
| download | vis-fbc6bb06953868562c8cac805c0997cd3a8e8ef9.tar.gz vis-fbc6bb06953868562c8cac805c0997cd3a8e8ef9.tar.xz | |
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 (limited to 'text-motions.c')
| -rw-r--r-- | text-motions.c | 8 |
1 files 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; |
