aboutsummaryrefslogtreecommitdiff
path: root/text-objects.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-08-29 13:32:41 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-08-29 13:52:17 +0200
commit6f0f448ef22a324cefce9e6ab7c89cae7d00a034 (patch)
treea7f5244acae7e25d8d08d2644f08c00e52d39f59 /text-objects.c
parent397a8a0688c0be874f0e1826ed51d88db039d769 (diff)
downloadvis-6f0f448ef22a324cefce9e6ab7c89cae7d00a034.tar.gz
vis-6f0f448ef22a324cefce9e6ab7c89cae7d00a034.tar.xz
text: make inner text objects work on single delimiting symbols
See #864
Diffstat (limited to 'text-objects.c')
-rw-r--r--text-objects.c14
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 */