From d68217c61f9c5d7bf79d3efa440a93f2761a3975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 7 Feb 2017 08:54:23 +0100 Subject: vis: improve text object handling Fix `gN` and delimited inner variants when given a count. --- vis.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 9a1dbaa..3e64031 100644 --- a/vis.c +++ b/vis.c @@ -776,13 +776,22 @@ void vis_do(Vis *vis) { r.end++; } - if (vis->mode->visual) + if (vis->mode->visual || (i > 0 && !(a->textobj->type & TEXTOBJECT_NON_CONTIGUOUS))) c.range = text_range_union(&c.range, &r); else c.range = r; - if (i < count - 1) - pos = c.range.end + 1; + if (i < count - 1) { + if (a->textobj->type & TEXTOBJECT_EXTEND_BACKWARD) { + pos = c.range.start; + if ((a->textobj->type & TEXTOBJECT_DELIMITED_INNER) && pos > 0) + pos--; + } else { + pos = c.range.end; + if (a->textobj->type & TEXTOBJECT_DELIMITED_INNER) + pos++; + } + } } } else if (vis->mode->visual) { c.range = view_cursors_selection_get(cursor); -- cgit v1.2.3