From c25e0c110430bd16056c6fe12e9e6676ebf1e5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 12 Apr 2017 21:50:56 +0200 Subject: sam: fix negative count specifiers from visual mode --- sam.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 0ade73a..f548744 100644 --- a/sam.c +++ b/sam.c @@ -1131,7 +1131,7 @@ static bool count_negative(Command *cmd) { if (cmd->count.start < 0 || cmd->count.end < 0) return true; for (Command *c = cmd->cmd; c; c = c->next) { - if (c->cmddef->func != cmd_extract) { + if (c->cmddef->func != cmd_extract && c->cmddef->func != cmd_select) { if (count_negative(c)) return true; } @@ -1147,7 +1147,7 @@ static void count_init(Command *cmd, int max) { if (count->end < 0) count->end += max; for (Command *c = cmd->cmd; c; c = c->next) { - if (c->cmddef->func != cmd_extract) + if (c->cmddef->func != cmd_extract && c->cmddef->func != cmd_select) count_init(c, max); } } @@ -1441,6 +1441,9 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur bool multiple_cursors = view_cursors_multiple(view); Cursor *primary = view_cursors_primary_get(view); + if (vis->mode->visual) + count_init(cmd->cmd, view_cursors_count(view)+1); + for (Cursor *c = view_cursors(view), *next; c && ret; c = next) { next = view_cursors_next(c); size_t pos = view_cursors_pos(c); -- cgit v1.2.3