diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-08-28 15:30:11 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-08-28 15:30:11 +0200 |
| commit | 63304991187eeefb656fdb4ba6fc04d21601ebae (patch) | |
| tree | a95801bab3c392bcfc1814403b08cb60983a2964 /text-objects.c | |
| parent | 191daea3627689121de3bac73961056426b943d3 (diff) | |
| download | vis-63304991187eeefb656fdb4ba6fc04d21601ebae.tar.gz vis-63304991187eeefb656fdb4ba6fc04d21601ebae.tar.xz | |
text-object: make word object behave more like in vim
Diffstat (limited to 'text-objects.c')
| -rw-r--r-- | text-objects.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/text-objects.c b/text-objects.c index f1181ef..121811d 100644 --- a/text-objects.c +++ b/text-objects.c @@ -17,25 +17,25 @@ Filerange text_object_word(Text *txt, size_t pos) { text_iterator_byte_next(&it, NULL); text_iterator_byte_next(&it, &next); if (isspace(c)) { - /* we are in the middle of two words */ + /* middle of two words, include leading white space */ r.start = text_char_next(txt, text_word_end_prev(txt, pos)); - r.end = text_word_start_next(txt, pos); + r.end = text_char_next(txt, text_word_end_next(txt, pos)); } else if (isspace(prev) && isspace(next)) { /* on a single character */ r.start = pos; - r.end = text_char_next(txt, pos); + r.end = text_word_start_next(txt, pos); } else if (isspace(prev)) { /* at start of a word */ r.start = pos; - r.end = text_char_next(txt, text_word_end_next(txt, pos)); + r.end = text_word_start_next(txt, text_word_end_next(txt, pos)); } else if (isspace(next)) { /* at end of a word */ r.start = text_word_start_prev(txt, pos); - r.end = text_char_next(txt, pos); + r.end = text_word_start_next(txt, pos); } else { /* in the middle of a word */ r.start = text_word_start_prev(txt, pos); - r.end = text_char_next(txt, text_word_end_next(txt, pos)); + r.end = text_word_start_next(txt, text_word_end_next(txt, pos)); } return r; } |
