vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 21b6e4604d60ebbb228d4b91e701bdae32714e61
parent cfd9a4468ecba3bfa9a80bfb6512dbef2702bc51
Author: Marc André Tanner <mat@brain-dump.org>
Date: Wed, 6 Apr 2016 12:13:01 +0200
text-motion: restore old text_{line_,}find_prev behavior
This partially reversts the "Fix to/till movements" commit
b479111c480acaf0979021c7b827709036dabf2d
The pos += len hunk was interfering with other code which does
not want this behavior. The original issue should be fixed directly
within the to/till movements.
Diffstat:
| M | text-motions.c | | | 4 | +--- |
| M | vis-motions.c | | | 10 | ++-------- |
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/text-motions.c b/text-motions.c @@ -70,11 +70,9 @@ static size_t find_prev(Text *txt, size_t pos, const char *s, bool line) { if (!s) return pos; size_t len = strlen(s), matched = len - 1; - Iterator it, sit; + Iterator it = text_iterator_get(txt, pos), sit; if (len == 0) return pos; - pos += len; - it = text_iterator_get(txt, pos); for (char c; text_iterator_byte_prev(&it, &c); ) { if (c == s[matched]) { if (matched == 0) diff --git a/vis-motions.c b/vis-motions.c @@ -89,20 +89,14 @@ static size_t till(Vis *vis, Text *txt, size_t pos) { } static size_t to_left(Vis *vis, Text *txt, size_t pos) { - char c; - if (pos == text_line_begin(txt, pos)) - return pos; - size_t hit = text_line_find_prev(txt, pos-1, vis->search_char); - if (!text_byte_get(txt, hit, &c) || c != vis->search_char[0]) - return pos; - return hit; + return text_line_find_prev(txt, pos, vis->search_char); } static size_t till_left(Vis *vis, Text *txt, size_t pos) { if (pos == text_line_begin(txt, pos)) return pos; size_t hit = to_left(vis, txt, pos-1); - if (hit != pos) + if (hit != pos-1) return text_char_next(txt, hit); return pos; }