Skip to content

Commit

Permalink
on <C-n>, flip new selection if the old selection was flipped
Browse files Browse the repository at this point in the history
raised in issue 1022: #1022
  • Loading branch information
jeremybobbin committed Mar 12, 2023
1 parent 4e8709a commit 4cb51ef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,25 +1394,35 @@ static const char *selections_match_next(Vis *vis, const char *keys, const Arg *
if (!buf)
return keys;

bool flip;
bool match_all = arg->b;
Filerange primary = range;
Selection *sel;

for (;;) {
flip = view_cursor_get(view) == primary.start;
range = find_next(txt, range.end, buf);
if (!text_range_valid(&range))
break;
if (selection_new(view, &range, !match_all) && !match_all)
if ((sel = selection_new(view, &range, !match_all)) && !match_all) {
if (flip)
view_selections_flip(sel);
goto out;
}
}

range = primary;

for (;;) {
flip = view_cursor_get(view) == primary.start;
range = find_prev(txt, range.start, buf);
if (!text_range_valid(&range))
break;
if (selection_new(view, &range, !match_all) && !match_all)
if ((sel = selection_new(view, &range, !match_all)) && !match_all) {
if (flip)
view_selections_flip(sel);
break;
}
}

out:
Expand Down

0 comments on commit 4cb51ef

Please sign in to comment.