Skip to content

Commit

Permalink
sam: execute commands even if we have no valid range
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martanne committed Feb 8, 2017
1 parent cebb24b commit 34f980b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 34f980b

Please sign in to comment.