diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-01-18 21:03:55 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-01-18 21:36:56 +0100 |
| commit | 6a015289b3cebe7d64c5aa14c3635349b053d07a (patch) | |
| tree | b9252bd61ed03889adcf51321a90ba876900655a | |
| parent | aaf443f64d36ad8f921d56387c806ae5fe1b7fa8 (diff) | |
| download | vis-6a015289b3cebe7d64c5aa14c3635349b053d07a.tar.gz vis-6a015289b3cebe7d64c5aa14c3635349b053d07a.tar.xz | |
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.
| -rw-r--r-- | vis-motions.c | 6 |
1 files 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; |
