From fc76731a8678f25d0b0e7baa429315536c49e16e Mon Sep 17 00:00:00 2001 From: Jeremy Bobbin Date: Sat, 11 Mar 2023 17:04:20 -0800 Subject: [PATCH] on , flip new selection if the old selection was flipped raised in issue 1022: https://github.com/martanne/vis/issues/1022 --- main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index c5d1bac25..21bb051d0 100644 --- a/main.c +++ b/main.c @@ -1394,25 +1394,37 @@ 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) - goto out; + if (sel = selection_new(view, &range, !match_all)) { + if (flip) + view_selections_flip(sel); + if (!match_all) + 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) - break; + if (sel = selection_new(view, &range, !match_all)) { + if (flip) + view_selections_flip(sel); + if (!match_all) + break; + } } out: