diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-08-29 13:32:41 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-08-29 13:52:17 +0200 |
| commit | 6f0f448ef22a324cefce9e6ab7c89cae7d00a034 (patch) | |
| tree | a7f5244acae7e25d8d08d2644f08c00e52d39f59 | |
| parent | 397a8a0688c0be874f0e1826ed51d88db039d769 (diff) | |
| download | vis-6f0f448ef22a324cefce9e6ab7c89cae7d00a034.tar.gz vis-6f0f448ef22a324cefce9e6ab7c89cae7d00a034.tar.xz | |
text: make inner text objects work on single delimiting symbols
See #864
| -rw-r--r-- | text-objects.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/text-objects.c b/text-objects.c index b3b9c69..7cedd3f 100644 --- a/text-objects.c +++ b/text-objects.c @@ -28,13 +28,19 @@ static Filerange text_object_customword(Text *txt, size_t pos, int (*isboundary) r.start = text_char_next(txt, text_customword_end_prev(txt, pos, isboundary)); r.end = text_customword_start_next(txt, pos, isboundary); } else if (boundary(prev) && boundary(next)) { - if (boundary(c)) { - r.start = text_char_next(txt, text_customword_end_prev(txt, pos, isboundary)); - r.end = text_char_next(txt, text_customword_end_next(txt, pos, isboundary)); - } else { + if ((space(prev) && space(next)) || !boundary(c)) { /* on a single character */ r.start = pos; r.end = text_char_next(txt, pos); + } else if (space(prev)) { + r.start = pos; + r.end = text_char_next(txt, text_customword_end_next(txt, pos, isboundary)); + } else if (space(next)) { + r.start = text_customword_start_prev(txt, pos, isboundary); + r.end = text_char_next(txt, pos); + } else { + r.start = text_customword_start_prev(txt, pos, isboundary); + r.end = text_char_next(txt, text_customword_end_next(txt, pos, isboundary)); } } else if (boundary(prev)) { /* at start of a word */ |
