From 6a015289b3cebe7d64c5aa14c3635349b053d07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 18 Jan 2016 21:03:55 +0100 Subject: 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. --- vis-motions.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vis-motions.c b/vis-motions.c index 9bd95b9..f95fcf1 100644 --- 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; -- cgit v1.2.3