vis

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

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

commit 21c72da6113abc939d075ccc359a2e50b2a9f735
parent 446246abd036f4556485349a76ac5a0def851075
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed,  8 Feb 2017 15:56:12 +0100

sam: execute commands even if we have no valid range

In an ideal world this should never happen. However,
if for some reason all cursors/selections become
invalid, default to an empty range. This at least
allows to terminate the editor gracefully whereas
before the command would silently be ignored.

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

diff --git a/sam.c b/sam.c @@ -1392,8 +1392,9 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur } else { sel = text_range_new(pos, text_char_next(txt, pos)); } - if (text_range_valid(&sel)) - ret &= sam_execute(vis, win, cmd->cmd, c, &sel); + if (!text_range_valid(&sel)) + sel = text_range_new(0, 0); + ret &= sam_execute(vis, win, cmd->cmd, c, &sel); if (cmd->cmd->cmddef->flags & CMD_ONCE) break; }