vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 58bec943cf3342ff5eb218fe4174824ca11ebfec
parent 8f988a2cbc214f6fac83f1b4778ba85fe56b9839
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 29 Aug 2020 13:32:41 +0200

text: make inner text objects work on single delimiting symbols

See #864

Diffstat:
Mtext-objects.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 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 */