diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-02-08 15:56:12 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-02-08 18:33:32 +0100 |
| commit | 34f980b539efdf4686e7b78e713c5c2dfcd428b7 (patch) | |
| tree | 1ea2a154e59517cc937c2538cdeb3e2bffd7a010 | |
| parent | cebb24b36ac45cc7c6912481cacd29ef9d5c68b9 (diff) | |
| download | vis-34f980b539efdf4686e7b78e713c5c2dfcd428b7.tar.gz vis-34f980b539efdf4686e7b78e713c5c2dfcd428b7.tar.xz | |
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.
| -rw-r--r-- | sam.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |
