diff options
| author | zsugabubus <zsugabubus@users.noreply.github.com> | 2020-01-12 15:57:48 +0100 |
|---|---|---|
| committer | zsugabubus <zsugabubus@users.noreply.github.com> | 2020-01-12 16:34:50 +0100 |
| commit | c9831b1120e7c29419183c5fde8cf1bf4e69d5bd (patch) | |
| tree | 64b3f425cd0211296e9f170154c898c843283538 /text-motions.c | |
| parent | e136e348cbd0ea4bf2dd8de6f98da1ca1924bc96 (diff) | |
| download | vis-c9831b1120e7c29419183c5fde8cf1bf4e69d5bd.tar.gz vis-c9831b1120e7c29419183c5fde8cf1bf4e69d5bd.tar.xz | |
vis: fix search wrapping bugs
1) “$” matches in the middle of the text.
visvis
^ - standing here
\/ - at first we search forward-\
\_/ - wrap, if nothing found <---/
After wrapping, in the second range “$” will treat end of the range
as EOL so “/vis$” will wisely match and moves cursor to the first
column.
2) No match after wrapping.
vissssss
^^ - standing here or here
\\____/ - search this before wrapping ---\
V - search range after wrapping <--/
“/vis” will *not* match (after wrapping), because it crosses ranges.
---
So the real solution would be that instead of the end position, the
start position of the possible match should be limited because a match
can cross the search ranges. To keep things simple, simply search two
whole text after wrapping.
visvis
\____/
Diffstat (limited to 'text-motions.c')
| -rw-r--r-- | text-motions.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/text-motions.c b/text-motions.c index 689bb1f..533d896 100644 --- a/text-motions.c +++ b/text-motions.c @@ -622,8 +622,7 @@ size_t text_search_forward(Text *txt, size_t pos, Regex *regex) { if (!found) { start = 0; - end = pos; - found = !text_search_range_forward(txt, start, end, regex, 1, match, 0); + found = !text_search_range_forward(txt, start, end - start, regex, 1, match, 0); } return found ? match[0].start : pos; |
