From 6f0f448ef22a324cefce9e6ab7c89cae7d00a034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 29 Aug 2020 13:32:41 +0200 Subject: text: make inner text objects work on single delimiting symbols See #864 --- text-objects.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'text-objects.c') 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 */ -- cgit v1.2.3