aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-03-28 11:02:33 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-03-28 12:25:06 +0200
commitf577616bcefac9480eef5f995bbc589b946e5c6b (patch)
tree8f6b008171b2336f36e8725c38e55e4b4e750988
parent86b1887aac82b86e1f2ad0f255bd872796dd4803 (diff)
downloadvis-f577616bcefac9480eef5f995bbc589b946e5c6b.tar.gz
vis-f577616bcefac9480eef5f995bbc589b946e5c6b.tar.xz
vis: Ctrl-{j,k} do not create duplicate cursors, instead advance primary one
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 3bd3d36..a5fc2d3 100644
--- a/main.c
+++ b/main.c
@@ -1232,7 +1232,14 @@ static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) {
view_line_up(cursor);
size_t newpos = view_cursors_pos(cursor);
view_cursors_to(cursor, oldpos);
- view_cursors_new(view, newpos);
+ if (!view_cursors_new(view, newpos)) {
+ if (arg->i == -1) {
+ cursor = view_cursors_prev(cursor);
+ } else if (arg->i == +1) {
+ cursor = view_cursors_next(cursor);
+ }
+ view_cursors_primary_set(cursor);
+ }
}
vis_count_set(vis, VIS_COUNT_UNKNOWN);
return keys;