vis

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

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

commit 6975658ae216dac19c00acaa67cb20349e876151
parent 0f3aa56e98b828a7f0c00978918bd8594cf377e2
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun, 15 Jan 2017 18:31:04 +0100

view: fix check to prevent duplicate cursor creation

Previously repeatedly pressing <Ctrl-j> at the start of the file
would keep creating cursors.

Diffstat:
Mview.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/view.c b/view.c @@ -940,7 +940,10 @@ static Cursor *cursors_new(View *view, size_t pos, bool force) { Cursor *prev = NULL, *next = NULL; size_t cur = view_cursors_pos(view->cursor); - if (pos >= cur) { + if (pos == cur) { + prev = view->cursor; + next = prev->next; + } else if (pos > cur) { prev = view->cursor; for (next = prev->next; next; prev = next, next = next->next) { cur = view_cursors_pos(next);