diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-03-28 23:13:57 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-03 13:22:14 +0200 |
| commit | c8e7be3107f39c32cf503db45a73b165659406c8 (patch) | |
| tree | 1e5abf595eb6cae7862b7f27d3424f4524b69f66 | |
| parent | efdca4894b0219d4e4f618f911863811a2d6711e (diff) | |
| download | vis-c8e7be3107f39c32cf503db45a73b165659406c8.tar.gz vis-c8e7be3107f39c32cf503db45a73b165659406c8.tar.xz | |
sam: remove old cursor/selection before executing command
Because duplicated cursors are no longer allowed we have to
remove the old cursors before, not after executing the sam
command. Otherwise commands like g/foo/ which re-create the
same selection fail.
| -rw-r--r-- | sam.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -729,6 +729,8 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, Filerange *range) { View *view = win->view; Text *txt = win->file->text; bool multiple_cursors = view_cursors_multiple(view); + size_t pos = view_cursor_get(view); + Cursor *cursor = NULL; for (Cursor *c = view_cursors(view), *next; c; c = next) { next = view_cursors_next(c); Filerange sel; @@ -743,9 +745,18 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, Filerange *range) { } else { sel = text_range_new(0, text_size(txt)); } + if (!view_cursors_dispose(c)) { + cursor = view_cursors_new(view, text_size(txt)+1); + view_cursors_dispose(c); + } ret &= sam_execute(vis, win, cmd->cmd, &sel); - view_cursors_dispose(c); } + + if (cursor && !view_cursors_dispose(cursor)) { + view_cursors_selection_clear(cursor); + view_cursors_to(cursor, pos); + } + return ret; } |
