vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 408c6c18f6ede2d19180d8c44dfea24cb77ebaa9 parent 2029ccf3a1e500d6efda46944b9bbdf225674648 Author: Marc André Tanner <mat@brain-dump.org> Date: Mon, 18 Jan 2016 21:03:55 +0100 vis: tweak count handling of till motions 't' and 'T' The behaviour when already in front of a match is deliberately different from vim. Based on a patch from Markus Teich. Diffstat:
| M | vis-motions.c | | | 6 | ++++-- |
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/vis-motions.c b/vis-motions.c @@ -57,7 +57,7 @@ static size_t to(Vis *vis, Text *txt, size_t pos) { } static size_t till(Vis *vis, Text *txt, size_t pos) { - size_t hit = to(vis, txt, pos); + size_t hit = to(vis, txt, pos+1); if (hit != pos) return text_char_prev(txt, hit); return pos; @@ -74,7 +74,9 @@ static size_t to_left(Vis *vis, Text *txt, size_t pos) { } static size_t till_left(Vis *vis, Text *txt, size_t pos) { - size_t hit = to_left(vis, txt, pos); + if (pos == 0) + return pos; + size_t hit = to_left(vis, txt, pos-1); if (hit != pos) return text_char_next(txt, hit); return pos;