vis

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

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

commit ff40a879aa9592ab774de7497ce6c3ded45ab127
parent 0d421fa4b7632468c945d38d87d35b211e272ac5
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 12 Apr 2017 21:50:56 +0200

sam: fix negative count specifiers from visual mode

Diffstat:
Msam.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 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);